Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Build your first Web Services with Tuscany

(star) "Creating Your First Web Service with Apache Tuscany video"
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.

If you haven't done this step already, please follow the instructions available in the link below :

Include Page
Tools - Install the Latest Tuscany Eclipse

...

Plugin
Tools - Install the Latest Tuscany Eclipse

...

Plugin

Create your Service Business Logic

...

Now that you have all the required service implementations you compose them together to provide
the store helloworld composite service. The composition is stored in a .composite file.

...

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<composite	 xmlns="http://www.osoa.org/xmlns/sca/1.0"
			    xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
			    xmlns:c="http://helloworld"
			    targetNamespace="http://helloworld"
    name="helloworld">


	<component name="HelloWorldComponent">
		<implementation.java class="helloworld.HelloWorldImpl"/>
		<service name="HelloWorld">
			<binding.ws uri="http://localhost:8080/HelloWorld"/>
		</service>
	</component>
</composite>

After completing these steps the content of the "storews" project will look as follows.

...

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>

You are finished. You have created the HelloWorld web service using Apache Tuscany.