An old fashion to build Axis Web Service (1)

WSDL Structure

<wsdl:definitions>

    <wsdl:types>

           <s:schema targetNamespace="xxxxxx">

                  <s:element name="bbb" type="s:ComplexType"/>

<s:element name="bbbResponse" type="s:ComplexType "/>

           </s:schema>

    </wsdl:types>

<wsdl:message name=" bbbSoapIn ">

<wsdl:part name="parameter" element="tns:bbb"/>

</wsdl:message>

<wsdl:message name=" bbbSoapOut ">

<wsdl:part name="parameter" element="tns:bbbResponse"/>

</wsdl:message>

    <wsdl:portType name="xxxPortType">

           <wsdl:operation name="zzz">

                  <wsdl:input message="tns:bbbSoapIn"/>

                  <wsdl:output message="tns:bbbSoapOut"/>

           </wsdl:operation>

</wsdl:portType>

    <wsdl:binding name="xxxSoapBinding" type="tns:xxxPortType">

<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

           <wsdl:operation name="store">

                  <soap:operation soapAction="http://localhost:8080/services/xxx/store" 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="xxxService">

           <wsdl:documentation>xxx Service</wsdl:documentation>

           <wsdl:port name="xxx" binding="tns:xxxSoapBinding">

                  <soap:address location="http://localhost:8080/services/xxx"/>

           </wsdl:port>

</wsdl:service>

</wsdl:definitions>

 

Few things need to be aware of in the structure of WSDL file, which have been highlighted above:

  • Message – if the parameter is complex type, element should be used

<wsdl:part name="parameter" element="tns:bbb"/>

            If it is a primitive (defined by the standard schema), may also use

<wsdl:part name="parameter" type="s:string"/>

Message for response of the web service should have their parameter named with “Response” suffix and input element must be the same as the operation name (This definitely works with RPC service and document, but not sure for the others)

 

Importing external schema

 

import schema

<s:schema targetNamespace="http://hongliang.com/webservice" xmlns:sapParam="urn:sapParam">

    <s:import namespace="urn:sapParam" schemaLocation="file:///C:/dev /mySchema.xsd"/>

    <s:element name="doTest">

       <s:complexType>

         <s:sequence>

             <s:element name="inputParam" type="sapParam:sap_import_main"/>

         </s:sequence>

       </s:complexType>

    </s:element>

    <s:element name="doTestResponse">

       <s:complexType>

         <s:sequence>

           <s:element name="reponseParam" minOccurs="1" type="s:string"/>

         </s:sequence>

       </s:complexType>

    </s:element>

</s:schema>

 

Few things you need to be aware while importing the external schema

    • You have to declare the namespace attribute for the import tag, in order to reference the schema content from WSDL (in s:schema xmlns:sapParam="urn:sapParam)
    • A brief introduction of schema is given in the later part of this article
    • There is a naming standard for using external schema, please check it for your preference.

 

Advertisements
This entry was posted in Web Service. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s