Versions Compared

Key

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

...

This guide will give you step by step instructions on how to build your first web services.
The first part, we will learn how we can add the Tuscany Runtime to Eclipse IDE.
The second part, will show how easy is to create a webservices using Apache Tuscany.

Include Page
TUSCANY:Tools - Install

...

The first thing you do is to start Eclipse and go to Help -> Software Updates -> Find and Install,
select "Search for new features to install" and then click next

Image Removed

On the next dialog, click on "New Remote Site..." to create a new site entry. Give it a name such as
"Tuscany" and add the site URL as *http://people.apache.org/~jsdelfino/tuscany/tools/updatesite/*Image Removed

Image Removed

Make sure the "Remote  Site" that was just created is selected, and click "Finish"

Image Removed

Select the "Apache Tuscany SCA Tools" and click "Next", and then, on the next dialog, click "Finish"

Image Removed

Accept the "Plugin License"

Image Removed

and next click on "Install All"

Image Removed

When asked to "restart eclipse", click the  "yes" button. 

Image Removed

Create your 1st Composite Service Application

The following shows the composition diagram for the composite service application you are about
to create.

Image Removed

The composite service application you will create is a composition of four services. The composed
service provided is that of an on-line store.
There is a Catalog service which you can ask for catalog items, and depending on its currency
code property configuration it will provide the item prices in USD or EUR. The Catalog service is not
doing the currency conversion itself it references a CurrencyConverter service to do that task. Then
there is the ShoppingCart service into which items chosen from the catalog can be added, it is
implemented as a REST service. The Catalog is bound using the JSONRPC binding, and the
ShoppingCart service is bound using the ATOM binding. Finally there is the Store user facing
service that provides the browser based user interface of the store. The Store service makes use of
the Catalog and ShoppingCart service using the JSONRPC, and ATOM binding respectively.

Tuscany Eclipse Plugins 1.1
TUSCANY:Tools - Install Tuscany Eclipse Plugins 1.1

Create your Service Business Logic

Create a Java Project

In this step you create a Java Project in Eclipse to hold the composite service application.
Click on the New Java Project button   in the toolbar to launch the project creation dialog.
Next you enter "ws" as the Project name, and for Project Layout select Create separate
folders for sources and class files.

 

 
Hit the Next button, and on the following page go to the Libraries tab. Use the Add Library...
button on the right to add the Tuscany Library library to the project.
 

 
 
Hit the Finish button to complete the New Java Project dialog to create the "store" java project. 
 

 
 

...

Code Block
package helloworld;
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface HelloWorld {
    String[] sayHello(String name);
}

Select the "helloworld" package again. Select the New Java Class button . In the dialog enter
"HelloWorldImpl" as the Name of the class, add "Catalog" as the interface this class implements, and
then select Finish to complete the dialog.

...

http://localhost:8080/HelloWorld?wsdl 

You should now have your web service live, and the url should give you back a generated wsdl for the service.

Code Block

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://helloworld" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns0="http://helloworld" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns:ns="http://helloworld">
         <xs:element name="sayHello">
            <xs:complexType>
               <xs:sequence>
                  <xs:element minOccurs="0" name="param0" nillable="true" type="xs:string"/>
               </xs:sequence>
            </xs:complexType>

         </xs:element>
         <xs:element name="sayHelloResponse">
            <xs:complexType>
               <xs:sequence>
                  <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
               </xs:sequence>
            </xs:complexType>
         </xs:element>
      </xs:schema>

  </wsdl:types>
  <wsdl:message name="sayHelloRequest">
    <wsdl:part name="parameters" element="ns0:sayHello">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="sayHelloResponse">
    <wsdl:part name="parameters" element="ns0:sayHelloResponse">
    </wsdl:part>
  </wsdl:message>

  <wsdl:portType name="HelloWorldPortType">
    <wsdl:operation name="sayHello">
      <wsdl:input message="ns0:sayHelloRequest" wsaw:Action="urn:sayHello">
    </wsdl:input>
      <wsdl:output message="ns0:sayHelloResponse" wsaw:Action="urn:sayHelloResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="HelloWorldHttpBinding" type="ns0:HelloWorldPortType">

    <http:binding verb="POST"/>
    <wsdl:operation name="sayHello">
      <http:operation location="HelloWorld/sayHello"/>
      <wsdl:input>
        <mime:content part="sayHello" type="text/xml"/>
      </wsdl:input>
      <wsdl:output>
        <mime:content part="sayHello" type="text/xml"/>
      </wsdl:output>

    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="HelloWorldSOAP11Binding" type="ns0:HelloWorldPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHello">
      <soap:operation soapAction="urn:sayHello" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>

      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="HelloWorld">
    <wsdl:port name="HelloWorldSOAP11port_http" binding="ns0:HelloWorldSOAP11Binding">
      <soap:address location="http://192.168.209.1:8080/HelloWorld"/>
    </wsdl:port>

    <wsdl:port name="HelloWorldHttpport" binding="ns0:HelloWorldHttpBinding">
      <http:address location="http://192.168.209.1:8080/HelloWorld"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>