Tech - Programming
By: - at May 27, 2013

Examples of WSDL - Web Service Description Language

Web Service Definition

WSDL (Web Service Description Language) for Web Services is the equivalent of IDL (Interface Definition Language) for distributed programming (CORBA, DCOM). This language can accurately describe Web Services, including details such as protocols, servers, ports used, the operations that can be performed, the formats of the input and output messages, and exceptions that can be returned. There were other attempts to solve the language problem of the definition of Web Services.

microsoft
By Ben Franske (Own work) [GFDL or CC-BY-SA-3.0-2.5-2.0-1.0], via Wikimedia Commons

Firstly Microsoft proposed SDL (Service Definition Language) with an implementation provided in their SOAP Toolkit and IBM proposed NASSL (Network Accessible Service Specification Language), which an implementation is provided in SOAP4J. Microsoft changed its initial specification and proposed SCL (SOAP Contract Language) and the stakeholders agreed on WSDL. WSDL is seen as an interface that is the entry point of any Web Service: There is the location of the service, and operations that can be invoked using SOAP.

Structure of a WSDL Document
A WSDL document contains one or more definitions of Web services incorporating the various components (data types, messages, port types, bindings and ports). It is also possible to use the tag <Import> to break and gather WSDL documents. As for SOAP, WSDL definition mentions Namespaces of reference where we find the XML Schema definitions of WSDL tags themselves. The general skeleton of a WSDL document is shown in the following diagram:

Web Service Description Structure

<definitions>
<message>
 ...
</ message>
<portType>
<operation> ... </ operation>
<operation> ... </ operation>
 ...
</ portType>
<binding>
 ...
</ binding>
<service>
<port> ... </ port>
<port> ... </ port>
</ service>
</ definitions>

A set of tags are used to define a service, and these parameters (input and output). <definitions>: This is the root of all WSDL documents. This element contains the service definition. This tag can contain attributes specifying the service name, and Namespaces. It contains three types of elements:

  • <message> and <portType>: These elements define the operations offered by the service, their input and output parameters , etc.. In particular, a <message> corresponds to an input or output parameter of a <operation>. A <portType> defines a set of operations. An <operation> defines a coupe input message / output message. For example, in Java, an operation is a method and a portType is an interface.
     
  • <binding>: This item combines a <portType> to a particular protocol. Possible bindings are SOAP, CORBA or DCOM. Currently only SOAP is used. It is possible to define a binding for each protocol supported.
     
  • <service>: This element specifies the additional information needed to invoke the service, and in particular the URI of the recipient. A <service> is modeled as a collection of ports, a <port> is the combination of a <binding> to an URI. Each WSDL element can be documented using the <documentation> element. This element contains information related to the understanding of the document by human users of the service. It is also possible to define complex data types in a <types> tag just before the <message> tag.

WSDL Example:
The following is a description of the Echo1 service defined by the following Java class:

Java To WSDL

Public class Echo1 {
public String echo1 (String message) {
return "Message received:" + message;
}
}

<definition
2. xmlns: xsd = "http://www.w3.org/1999/XMLSchema"
3. xmlns: soap = "http://schemas.xmlsoap.org/wsdl/soap/">
4.
5. <message name = "echo1Input">
6. <part name = "expression" type ="xsd:string"/>
7. </ message>
8.
9. <message name = "echo1Output">
10. <part name = "expression" type = "xsd:string"/>
11. </ message>
12.
13. <portType name= "Echo1PortType">
14. <operation name = "echo1">
15. <input message = "echo1Input"/>
16. <output message = "echo1Output"/>
17. </ operation>
18. </ portType>
19.
20. <binding name= "Echo1SoapBinding" type ="tns:Echo1PortType">
21. <soap: binding style = "document"
22. transport = "http://schemas.xmlsoap.org/soap/http" />
23. <operation name = "echo1">
24. <soap:operation soapAction = "urn:ServiceEcho1"/>
25. <input>
26. <soap: body use = "encoded"
27. encodingStyle =
28. "http://schemas.xmlsoap.org/soap/encoding/" />
29. </ input>
30. <output>
31. <soap: body use = "encoded"
32. encodingStyle =
33. "http://schemas.xmlsoap.org/soap/encoding/" />
34. </ output>
35. </ operation>
36. </ binding>
37.
38. <service name = "Echo1Service">
39. <port name = "Echo1Soap" binding = "tns:Echo1SoapBinding">
40. <soap: address
41. location = "http://www.improve.fr/ServiceEcho1" />
42. </ port>
43. </ service> </ definition>

Explanation:
(5-11) The first part of the file defines the input and output parameters of service operations: echo1Input and echo1Output.

(13-18)The abstract definition of the Web service is made by the portType definition that encapsulates the definition of echo operation. This refers to messages previously defined (input and output parameters of the operation). We obtain an abstract service description, independent of any communication protocol. This is the service interface that defines the methods exported, and their input and output parameters.

(20-36) It is possible to combine this service with an existing protocol, by the definition of a binding (for example, we are interested in: SOAP). The binding defines the invocation parameters of specific service operating to the used protocol. Here we define the parameters required to use the service through SOAP (link to the specifications of transport used, encoding rules for serialization of exchanged messages, etc..).

(38-43) The service definition ends with the definition of the remaining parameters. For example, for a SOAP binding, it remains to define the URL address of the service to invoke. Note that it is possible to define multiple bindings, and to associate these bindings to multiple URLs by using the same abstract service definition.

WSDL Creation Tips
For a maximum of interoperability while maintaining flexibility, here are some tips to create a WSDL document:

  1. Always Document your WSDL file, both through the documentation tag, and by providing documentation in an external file to the WSDL document.
     
  2. Use the XML Schema Recommendation 2001. You can put many things in the item types of a WSDL document: Relax NG, an old version of XML Schema or anything else, but the safest and interoperable method is the 2001 version of Schema.
     
  3. Use the element types :Even if the messages have a simple data type, you must still use the types element to describe everything. In any case, do not refer to types in the element message.
     
  4. Divide your WSDL document into several pieces by leveraging the import function: create a file for the abstract aspect of WSDL, one for links and one for the service features and ports.
     
  5. Start designing your service by WSDL, and keep the interface unchanged from end to end, even if the WSDL is generated by the tools. This means that you will often compare your code to WSDL.


 

 

 

 

Programming
Introduction to Java EE (Part 1)
How the Google App Engine Works
WSDL - Web Service Description Language
SOAP: Simple Object Access Protocol
Initiation to Cryptography and Encryption to Secure Data
Introduction to Design Patterns in Java
How To Write Efficient Programs in Java
Proper Management of Logs in .Net
How To Remove FaceBook Action Ids From URL

Programming


Copyright 2017 YurTopic All rights reserved.

Protected by Copyscape Online Plagiarism Software

There has been a total of

hits counter
Unique Visitors to YurTopic
(Since January 1st 2013)

About  |  Terms and Conditions  |  Contact