Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

helloworld-contribution

This is the simplest a simple SCA contribution. This contribution It describes a composite application with a single component, HelloWorldComponent, implemented in Java. The component's Java implementation provides service "business logic" for saying hello to a person whose name is supplied as input to the service.

Panel
bgColorpink

To build this contribution using Ant do the following:

TODO

...

bgColorsilver

To build this contribution using Maven do the following:

Code Block

cd helloworld-contribution
mvn

...

The component is described in a composite called helloworld.composite as follows:

Code Block

helloworld-contribution/target/helloworld-contribution.jar

You can run the contribution using Maven by doing the following:

Code Block

cd helloworld-contribution
mvn tuscany:run
Note
titleTODO

And then what? (warning)

<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
           targetNamespace="http://sample"
           name="helloworld">

    <component name="HelloworldComponent">
        <implementation.java class="sample.HelloworldImpl"/>
    </component>

</composite>

The contribution also contains a composite called helloworldws.composite which describes a component, HelloworldWSComponent, that uses the same implementation but uses a web services binding:

Code Block

<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
           targetNamespace="http://sample"
           name="helloworldws">

    <component name="HelloworldWSComponent">
        <implementation.java class="sample.HelloworldImpl"/>
        <service name="Helloworld">
           <binding.ws />
        </service>
    </component>

</composite>

This gives us a number of options for interacting with the components in this application.

Firstly there is a JUnit test inside this project called HelloworldTestCase.java. This starts the Tuscany runtime and loads the contribution. It then talks to the HelloworldComponent over the default SCA binding (binding.sca) using a local Java proxy.

Secondly the HelloworldWSComponent exposes a service with a web services binding. You can talk to this component using your favourite web services client. You can retrieve the WSDL for the web service automatically (see later)

Panel
bgColorpink

To build this contribution using Ant do the following:

TODO

Panel
bgColorsilver

To build this contribution using Maven do the following:

Code Block

cd helloworld-contribution
mvn

This will produce the contribution as follows:

Code Block

helloworld-contribution/target/helloworld-contribution.jar

As the JUnit test deploys and runs the contribution we can use it as a first simple example of a running SCA application.

Panel
bgColorpink

To run the JUnit test using Ant do the following:

TODO

Panel
bgColorsilver

The contribution will be run automatically during the Maven build step and you will see the output from the JUnit test printed on the console in amongst the other output:

Code Block

Response from helloworld.sayHello("Petra") = Hello Petra

To access the web service that the HelloworldWSComponent exposes we have to keep the runtime runntime running.

Panel
bgColorpink

To run the sample Ant so that you can access the web service do the following:

TODO

Panel
bgColorsilver

We have a Maven plugin that will run SCA contributions. You use it in Maven as follows:

Code Block

cd helloworld-contribution
mvn tuscany:run

You will note that in the console output you can see a web service being exposed by the binding.ws JAXWS provider:

Code Block

Binding.ws JAXWS provider - Service URI: http://localhost:8085/HelloworldWSComponent/Helloworld

If you point you web browser at this address and add ?wsdl on the end:

Code Block

http://localhost:8085/HelloworldWSComponent/Helloworld?wsdl

You'll see the WSDL for the service returned. Using you're favourite web services client, for example, the Web Services Explorer in Eclipse, you can send messages to this web service.

When you're done use CTRL-C to stop the sample.

Note
titleTODO

need description of structure and operation this application once we've decided what that should be

For more information on getting started with the Apache Tuscany SCA Java runtime see the getting started page.

...

This sample is not a contribution in it's own right but demonstrates how to run the helloworld-contribution inside a web application. As it's the same contribution the same two components, HelloworldComponent and HelloworldWSComponnet, will be started.

Panel
bgColorpink

To build this contribution using Ant do the following:

TODO

Panel
bgColorsilver

To build this contribution using Maven do the following:

Code Block
cd helloworld-webapp
mvn

This will produce a webapp as follows:

Code Block

helloworld-webapp/target/helloworld.war

You can run this webapp by deploying it to you're favourite webapp container. For example, you can deploy to Tomcat and run as follows:

This sample webapp doesn't provide any web pages so how to make it do something?
Code Block
cp helloworld-webapp/target/helloworld.war my_tomcat_install/webapps
my_tomcat_install/bin/catalina run
Note
titleTODO

Once running point your web browser at:

Code Block

http://localhost:8080/helloworld/hello.html

You'll see a link there to the WSDL that's automatically generated for the web service binding of the HelloworldWSComponent. Again you can use your favourite web services client to send messages to the service.

Note
titleTODO

need description of structure and operation this application once we've decided what that should beThere is no example of accessing binding.sca from within the webapp. Do we want to include this?

Note
titleTODO

For more information on creating webapps to run SCA contributions with Tuscany see - ?

...