Sunday, October 7, 2012


WSDL stands for Web Service Description Language. as the full form suggests it is a document that describes Web Service.

WSDL is used to specify the exact
  •  message format,
  • Internet protocol,
  • and address 

that a client must use to communicate with a particular Web service.

Note :- that WSDL 1.1 is not specific to SOAP; it can be used to describe non-SOAP-based Web services as well.

A WSDL document contains seven important elements: types, import, message, portType, operations, binding, and service, which are nested in the definitions element.

A WSDL description of a "stock quote" service:

<?xml version="1.0"?>
<definitions name="StockQuote"

    <schema targetNamespace=""
      <element name="TradePriceRequest">
            <element name="tickerSymbol" type="string"/>
      <element name="TradePrice">
             <element name="price" type="float"/>

  <message name="GetLastTradePriceInput">
    <part name="body" element="xsd1:TradePriceRequest"/>

  <message name="GetLastTradePriceOutput">
    <part name="body" element="xsd1:TradePrice"/>

  <portType name="StockQuotePortType">
    <operation name="GetLastTradePrice">
      <input message="tns:GetLastTradePriceInput"/>
      <output message="tns:GetLastTradePriceOutput"/>

  <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
    <soap:binding style="document" transport=""/>
    <operation name="GetLastTradePrice">
      <soap:operation soapAction=""/>
        <soap:body use="literal"/>
        <soap:body use="literal"/>

  <service name="StockQuoteService">
    <documentation>My first service</documentation>
    <port name="StockQuotePort" binding="tns:StockQuoteSoapBinding">
      <soap:address location=""/>


  • some data types are defined using XML Schema
  • some simple message types are defined from the data types
  • the port type describes a single operation GetLastTradePrice, which uses the message types for input/output
  • the binding tells that the communication is through SOAP
  • the port associates the binding with the URI where the running service can be accessed

The XML Declaration
< ? xml version= " 1 . 0 " encoding = " UTF-8 " ? >
A WSDL document must use either UTF-8 or UTF-16 encoding; other encoding systems are not allowed.

The Definitions Element
The root element of all WSDL documents is the definitions element, which encapsulates the entire document and also provides a WSDL document with its name.

The definitions element usually contains several XML namespace declarations, which is normal for a root element. 

Name attribute is not important nothing refers to it, its optional.
The definitions element also declares a targetNamespace attribute, which identifies the namespace of elements defined in the WSDL document—much as it does in XML schema documents.

The types Element
The types element serves as a container for defining any data types that are not described by the XML schema built-in types: complex types and custom simple types.
You can also define an array type inside type.

The Import Element
The import element makes available in the present WSDL document the definitions from a specified namespace in another WSDL document. This feature can be useful if you want to modularize WSDL documents—for example, to separate the abstract definitions (the types, message, and portType elements) from the concrete definitions (the binding, service, and port elements).

 Use of the import element is convenient, but it can also create versioning headaches. If WSDL documents are maintained separately, the risk of an imported document being changed without regard to the WSDL documents that import it is pretty high. Take care to ensure that imported WSDL documents are not changed without considering versioning.

You can use import and types together, but you should list the import elements before the types element in a WSDL document.

The WSDL Abstract Interface the message type , portType , and Operations Element
The abstract interface of the Web service is described by
  •          message,
  •          portType,
  •         and operation elements
Can be simple or complex or simple custom
Like a java method , defines input & output messages for an operation.
Port Type
Like interface ( collections of operation )

The Message Type
describes outgoing and ingoing messages. The way to define a message element depends on whether you use RPC-style or document-style messaging.

They may describe
  •         call parameters,
  •         call return values,
  •         header blocks,
  •         or faults
        A message part may declare either a type attribute or an element attribute, but not both. Which to use depends on the kind of messaging you're doing. If you're using RPC-style messaging, the part elements must use the type attribute; if you're using document-style messaging, the part elements must use the element attribute

     RPC Style 
<definitions name="BookPrice" ...>
  <message name="GetBulkBookPriceRequest">
    <part name="isbn" type="xsd:string"/>
    <part name="quantity" type="xsd:int"/>
  <message name="GetBulkBookPriceResponse">
    <part name="price" type="mh:prices" />

Document Style
<message name="SubmitPurchaseOrderMessage">
    <part name="order" element="mh:purchaseOrder" />

The Port Type
A portType defines the abstract interface of a Web service.
The "methods" of the portType are its operation elements.

Binding Element
 The binding element maps an abstract portType to a set of
·         concrete protocols such as SOAP and HTTP,
·         messaging styles (RPC or document),
·         and encoding styles (Literal or SOAP Encoding).

The Service and port elements
The service element contains one or more port elements, each of which represents a different Web service.

No comments: