Chapter 5. Building distributed SCA applications

Table of Contents

Hello World with Web Services
Expose the SCA service as a web service
Consume the webservice from a remote client
Calling a Weather service from FraSCAti
Weather service interface
Weather client implementation
Weather composite
Test the weather example
Configuration of webservice bindings

This chapter aims at illustrate building of distributed applications with SCA. In the first section we will use the previous HelloWorld example. We will show that client and server components can be distributed easily using the composite definition. In the second section we will give an example of an SCA client which use webservice binding to call a weather service over Internet.

Hello World with Web Services

This section will show how to expose an SCA service as a web service, or how to bind an SCA reference to external web service.

Expose the SCA service as a web service

Exporting an SCA service as a web service is very easy, as it doesn't require any SCA specific code. It is sufficient to add a binding.ws element as subelement of the service definition and to define the URI to which make available the web service.

Note

No SCA specific code is needed.

  1 <?xml version="1.0" encoding="ISO-8859-15"?>
  2 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
  3            name="helloworld-ws-server">
  4 
  5   <component name="server">
  6     <implementation.java class="org.ow2.frascati.examples.helloworld.annotated.Server"/>
  7     <service name="printService">
  8       <binding.ws uri="http://localhost:8080/PrintService"/>
  9     </service>
 10   </component>
 11 
 12 </composite>
 13 

Consume the webservice from a remote client

The PrintService is now available as a web service. Using this service is easily doable by setting the webservice binding on the client component.

  1 <?xml version="1.0" encoding="ISO-8859-15"?>
  2 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
  3            xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
  4            name="helloworld-ws-client">
  5 
  6   <service name="r" promote="client/r">
  7     <interface.java interface="java.lang.Runnable" />
  8   </service>
  9 
 10   <component name="client">
 11     <reference name="printService">
 12       <binding.ws wsdli:wsdlLocation="http://localhost:8080/PrintService?wsdl"
 13                   wsdlElement="http://annotated.helloworld.examples.frascati.ow2.org#wsdl.port(PrintService/PrintServicePort)"/>
 14     </reference>
 15     <implementation.java class="org.ow2.frascati.examples.helloworld.annotated.Client" />
 16   </component>
 17 
 18 </composite>
 19 

Note

For a remote execution, replace localhost with the IP or name of the host.