Tuscany Hello World WS Client Sample

Overview

The Tuscany hello world WS client sample shows using the Tuscany SCA runtime in a J2SE environment invoking a web service.

Location

This sample is located  in the samples\sca\helloworldwsclient directory.

Setup

This sample depends on the Tuscany runtime, Axis2, and the sample jar, sample-helloworldwsclient-incubating-M1.jar , all of these must be available on the classpath to run the sample. Additionally, one of the helloworld web services must be running, either the Tomcat version, helloworldws sample or the Celtix version, helloworldws-celtix sample.

Running

In the directory samples/sca/helloworldwsclient use the JDK 1.5 java command to run the class helloworld.HelloWorldClient
Linux: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar:../../../lib/axis2/tuscany-axis2-incubating-M1.jar:target/sample-helloworldwsclient-incubating-M1.jar helloworld.HelloWorldClient
Windows: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar;../../../lib/axis2/tuscany-axis2-incubating-M1.jar;target/sample-helloworldwsclient-incubating-M1.jar helloworld.HelloWorldClient
Note: In the above classpaths, you can replace axis2/tuscany-axis2-incubating-M1.jar with celtix/tuscany-celtix-incubating-M1.jar to use Celtix as the underlying webservices implementation.

Results

The sample when run should simply display to the standard output:
Hello World

Code Overview

The source files are physically organized as shown below:
src
+---main
+---java
¦ +---helloworld
¦ HelloWorldClient.java
¦ HelloWorldService.java
¦
+---resources
¦ logging.properties
¦ sca.module
¦
+---wsdl
helloworld.wsdl





sca.module Defines the SCA module, externalService and component. Defines for the HelloWorldServiceComponent component and the Java class that implements the component For the externalService it defines WSDL for the service, the Java interface provided by the service. The the HelloWorldServiceComponent is via a referenced wired to the externalService
HelloWorldClient.java Creates a Tuscany runtime and starts it.  Obtains the module context which was defined by the sca.module file. From the module context locates the HelloWorldService entryPoint and then calls  the getGreetings method to invoke the web service defined in the helloword.wsdl.
HelloWorldService.java Defines the Java interface implemented by the component.
helloworld.wsdl WSDL for the service.