Reviews
SOA Web ServicesSOA Web Services - Writing Interoperable WSDL Definitions
Writing Interoperable WSDL Definitions
As seen from the discussions in the earlier sections, web services technology can easily be used to implement SOA and to integrate applications running on different platforms. Every platform has its own data representation format and data type system.
A web service must provide a universally accepted data type system to take care of the disparities in data types of various platforms. WSDL too, which is a grammar to describe the web service interface, must support interoperability. Although WSDL is not a mandatory requirement in the implementation of web services, it is widely supported. Thus, it is very important for us to understand how to create interoperable WSDL. To create an interoperable WSDL, the developer needs to create a WSDL that is compliant with the Basic Profile defined by WS-I (Web Service Interoperability Organization). The Basic Profile is discussed in the next section. The problem is that in many cases WSDL is created easily with the vendor tools and this WSDL may not truly comply with the Basic Profile.
To create a WSDL compliant to the WS-I Basic Profile, you will need to code it by hand and then verify it with the WS-I provided tools. Writing WSDL by hand is not only time consuming but it is also error prone. Thus, most times it is easier to use vendor-specific auto-generated WSDL. This WSDL may then be modified to remove any platform-specifi c idiosyncrasies.
The following Listing gives a template for WSI Basic Profile-compliant WSDL. You may use this template to easily create a compliant WSDL for your web services.
- <!--l version="1.0" encoding="utf8-->
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:tns="http://www.mycompany.com
- targetnamespace="http://www.mycompany.com" target="_blank" rel="nofollow">
- <wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema" target="_blank" rel="nofollow">
- <xsd:schema targetnamespace=" " elementformdefault="qualified">
- <xsd:element type="tns:Element1Type" name="MyElement1">
- </xsd:element>
- <xsd:complextype name="Element1Type">
- <xsd:sequence>
- <xsd:element type="xsd:int" name="First"></xsd:element>
- <xsd:element type="xsd:int" name="Second"></xsd:element>
- </xsd:sequence>
- </xsd:complextype>
- <xsd:element type="tns:Element2Type" name="MyElement2">
- </xsd:element>
- <xsd:complextype name="Element2Type">
- <xsd:sequence>
- <xsd:element type="xsd:int" name="First"></xsd:element>
- <xsd:element type="xsd:int" name="Second"></xsd:element>
- </xsd:sequence>
- </xsd:complextype>
- </xsd:schema>
- </wsdl:types>
- <wsdl:message name="InputMessage">
- <wsdl:part name="InputDocument" element="tns:MyElement1">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="OutputMessage">
- <wsdl:part name="OutputDocument" element="tns:MyElement2">
- </wsdl:part>
- </wsdl:message>
- <wsdl:porttype name="MyWebServicePortType">
- <wsdl:operation name="requestResponseMyServiceOperation">
- <wsdl:input message="tns:InputMessage" />
- <wsdl:output message="tns:OutputMessage"></wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="oneWayOperation">
- <wsdl:input message="tns:InputMessage" />
- </wsdl:operation>
- </wsdl:porttype>
- <wsdl:binding type="tns:MyWebServicePortType"
- name="MyWebServiceSoap"
- xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:http="http://schemas.xmlsoap.org/wsdl/http/">
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http">
- </soap:binding>
- <wsdl:operation name="requestResponseMyServiceOperation">
- <soap:operation soapaction=
- "http://www.mycompany.com/OutputMessage" target="_blank" rel="nofollow">
- </soap:operation>
- <wsdl:input>
- <soap:body use="literal"></soap:body>
- </wsdl:input>
- <wsdl:output>
- <soap:body use="literal"></soap:body>
- </wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="oneWayOperation">
- <soap:operation soapaction="http://www.mycompany.com/InputMessage" target="_blank" rel="nofollow">
- </soap:operation>
- <wsdl:input>
- <soap:body use="literal"></soap:body>
- </wsdl:input>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="MyWebService">
- <wsdl:port name="MyWebServiceSoap" binding="tns:
- MyWebServiceSoap">
- <soap:address location="http://localhost/WebApplication1/
- MyWebService.asmx"></soap:address>
- </wsdl:port>
- </wsdl:service>
- </wsdl:definitions>
The template shown in the above listing contains a single request/response operation and a single one-way operation. The template also defines two types and the two corresponding elements MyElement1 and MyElement2. You may modify the template and add more operations and types as required by your service. Using this template, you can now easily create an interoperable WSDL that is compliant to the Basic Profile by following the simple steps listed next:
1. Replace all occurrences of MyWebService with the name of your web service.
2. Replace all occurrences of http://www.mycompany.com with the namespace of your service.
3. Define the complex data types required by your service by modifying the code shown below. Assign an appropriate name for your data type and create the desired sequence of data types for your desired new complex data type.
- <xsd:element type="tns:Element1Type" name="MyElement1">
- </xsd:element>
- <xsd:complextype name="Element1Type">
- <xsd:sequence>
- <xsd:element type="xsd:int" name="First">
- </xsd:element>
- <xsd:element type="xsd:int" name="Second">
- </xsd:element>
- </xsd:sequence>
- </xsd:complextype>
- <xsd:element type="tns:Element2Type" name="MyElement2">
- </xsd:element>
- <xsd:complextype name="Element2Type">
- <xsd:sequence>
- <xsd:element type="xsd:int" name="First"></xsd:element>
- <xsd:element type="xsd:int" name="Second"></xsd:element>
- </xsd:sequence>
- </xsd:complextype>
4. Define input and output messages for your service. We assume a document-centric service here. Assign the desired name for the messages and select the appropriate data types. You can do so by replacing the attribute values for the name, part, and element tags in the code below:
- <wsdl:message name="InputMessage">
- <wsdl:part name="InputDocument" element="tns:MyElement1">
- </wsdl:part>
- </wsdl:message>
- <wsdl:part name="OutputDocument" element="tns:MyElement2">
- </wsdl:part>
5. In the portTypetag you will need to set the operations required by your web service. This may be one-way or request/response type. In the code below two operations are shown. The first one is of type request/response and the second one is of type one way. Modify this code to assign the desired names for the operations and assign the appropriate input and output messages defined earlier in your WSDL schema.
- <wsdl:operation name="requestResponseMyServiceOperation">
- <wsdl:input message="tns:InputMessage" />
- <wsdl:output message="tns:OutputMessage"></wsdl:output>
- </wsdl:operation>
- <wsdl:input message="tns:InputMessage" />
6. Assign the desired name and type for the binding in the wsdl:binding tag.
- <wsdl:binding type="tns:MyWebServicePortType"
- name="MyWebServiceSoap">
- </wsdl:binding>
7. In the operation tag set the desired operation name, specify the desired soapAction and the inputand output by modifying the following lines of code. This code represents the request/response type of operation.
- <wsdl:operation name="requestResponseMyServiceOperation">
- <soap:operation soapaction="http://www.mycompany.com/OutputMessage" target="_blank" rel="nofollow">
- </soap:operation>
- <wsdl:input>
- <soap:body use="literal"></soap:body>
- </wsdl:input>
- <wsdl:output>
- <soap:body use="literal"></soap:body>
- </wsdl:output>
- </wsdl:operation>
8. For one-way operation, make modifications similar to the previous bulleted item in the code lines below:
- <soap:operation soapaction=
- "http://www.mycompany.com/InputMessage" target="_blank" rel="nofollow">
- </soap:operation>
- <soap:body use="literal">
- </soap:body>
9. Finally, modify the following line in the service tag to specify the URL for your service.
- <soap:address location=
- "http://www.yourCompany.com/WebApplication1/MyWebService.asmx" target="_blank" rel="nofollow">
- </soap:address>
SOA Web Services
- SOA Web Services - SOA and Web Services Approach for Integration
- SOA Web Services - SOA Evolution
- SOA Web Services - IT Evolution
- SOA Web Services - Patterns
- SOA Web Services - Designing Sound Web Services
- SOA Web Services - Self-Service Business Pattern
- SOA Web Services - Extended Enterprise Business Pattern
- SOA Web Services - Application Integration Pattern
- SOA Web Services - Direct Connection Application Pattern
- SOA Web Services - Broker Application Pattern
- SOA Web Services - Serial Process Application Pattern
- SOA Web Services - Parallel Process Application Pattern
- SOA Web Services - Runtime Patterns
- SOA Web Services - Direct Connection Runtime Pattern
- SOA Web Services - Direct Connection Pattern
- SOA Web Services - Runtime Patterns for Broker
- SOA Web Services - Differences between B2B and EAI Web Services
- SOA Web Services - Writing Interoperable WSDL Definitions
- SOA Web Services - Validating Interoperable WSDL
- SOA Web Services - WS-I Specifications
- SOA Web Services - WS-I Basic Security Profile 1.0
- SOA Web Services - Guidelines for Creating Interoperable Web Services
- SOA Web Services - Java EE and .NET Integration using Web Services
- SOA Web Services - WSDL for Java Web Service
- SOA Web Services - Developing the .NET Web Service
- SOA Web Services - Developing the Test Client







