Wednesday, March 2, 2011

WSDL – What, Where and How

    In this article we briefly discuss the Web Service Description Language or WSDL. To know about the basis of WSDL and where they fit in the context of Web Services please read here. WSDL (generically Service Description, SD) is a XML based document that lets us describe the complete information of a service offering. It can contain definitions for the following things related to a web service:

  • Types – Allows for custom data type definition
  • Message – Defines data being sent to, and received from, the web service
  • Operation – Defines one abstract operation supplied by the web service
  • Port Type – Defines an interface, consisting of one or more operations of a web service
  • Binding – Specifies the protocol and data format to be used by a particular port type
  • Port – Defines an web service endpoint by assigning a network address to a binding
  • Service – The grouping of one or more web service endpoint(s)




The picture above shows the basic structure of a WSDL. A WSDL is divided into 2 main parts the abstract definition and the concrete definition. The abstract definition deals with the "What" part of the service, ("What" – What are the operations provided, What are the data needed,). The concrete definition deals with the "Where" and "How" part of a service description (Where is the service located, How is the request shaped and How is the service accessed).

When we try to map a WSDL to an implementation code (like Java) the abstract definition part of the WSDL maps to a set of interfaces which contains all the exposed operations, parameters that need to be passed and the return types. The message elements are mapped to POJO's whose structure is governed by the wsdl:type defined schema. These message types serve as the parameters passed in a method/operation. A single portType element is directly mapped to an Interface (popularly known as Service Endpoint Interface or SEI) which enlists all the operations enclosed within that portType. The operation tag contains the information pertaining to the input to be passed (wsdl:input), return type (wsdl:output) and custom faults (wsdl:fault). The other information that we can gather from the operation tag is whether it is a one-way operation or a request-response model. Based on the above information we can have the basic information of "What" the service has to offer. However we still do not know "How" this information is encoded into a message.

The concrete definition elements of the WSDL structure provides the information regarding "How" should the message be shaped? What element should go in the body and what element in the Head? Which protocol does the service use? Where is the service located? The binding is the most important element when it comes to giving information related to the message structure. The binding tag is mapped to a portType tag and follows the same structure. The only difference is that the binding tag has provision for "extensions". These extensions allow us to bind an implementation to the abstract portType. We can specify the format of the message (SOAP), format of message (which of the parameters are passed in the soap:head or soap:body), the network protocol used for communication. It also provides data regarding the SOAP Encoding. To know more about the syntax of these elements please read here.




No comments:

Post a Comment