Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Overview of WSDL

 
By James Kao, August 17, 2001  

Web Service Description Language (WSDL) is an XML language that contains information about the interface, semantics and "administrivia" of a call to a Web service.

Once you have developed a Web service, you publish its description and a link to it in a UDDI (Universal Description, Discovery and Integration) repository so that potential users can find it. When someone thinks they want to use your service, they request your WSDL file in order to find out the location of the service, the function calls and how to access them. Then they use this information in your WSDL file to form a SOAP (Simple Object Access Protocol) request to your computer.

The WSDL Standard

The WSDL standard is being worked out by the W3C (World Wide Web Consortium). That body further defines the standard as "an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate."

A Java API for WSDL (JWSDL)

A Java API for WSDL (JWSDL) specification is currently in the works in the Java Community Process (JCP). When released, it will provide an API for manipulating WSDL documents without directly interacting with the XML documents. While you can currently achieve the full range of WSDL functionality using JAXP, JWSDL will be much easier and faster to use, simplifying the developer's work.

How WSDL Works in the World of Java Technology

The following diagram illustrates how a Web service is registered, found and called in a scenario based on Java technology. In this diagram, the Web service is registered in a UDDI repository using the Java API for XML Registries (JAXR), where a business partner or other system can find the service. The registry information from UDDI is used to locate a WSDL document that details the call semantics for the Web service. With the WSDL document in hand, the Java programmer can then feed it to a tool that can generate a Java object proxy to the Web service, or simply use it as a reference document along with a lower-level SOAP API.

Figure 1: How WSDL works
Figure 1: How WSDL works
(Click image to enlarge.)

A Sample WSDL Definition

The WSDL definition shown in the example below contains the following key pieces of information:

  • A description/format of the messages that can be passed (via embedded XML Schema Definitions) within the <types> and <message> elements

  • The semantics of the message passing (e.g. Request-only, request-response, response-only) within the <portType> element

  • A specified encoding (various encodings over a specified transport such as HTTP, HTTPS, or SMTP) within the <binding> element

  • The endpoint for the service (a URL) within the <service> element
<?xml version="1.0"?>
<definitions name="StockQuote"
  targetNamespace=
    "http://example.com/stockquote.wsdl"
  xmlns:tns="http://example.com/stockquote.wsdl"
  xmlns:xsd1="http://example.com/stockquote.xsd"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
   <schema targetNamespace=
     http://example.com/stockquote.xsd
     xmlns="http://www.w3.org/2000/10/XMLSchema">
      <element name="TradePriceRequest">
        <complexType>
           <all>
             <element name="tickerSymbol" 
               type="string"/>
           </all>
        </complexType>
      </element>
      <element name="TradePrice">
        <complexType>
          <all>
            <element name="price" type="float"/>
          </all>
        </complexType>
      </element>
   </schema>
</types>
   <message name="GetLastTradePriceInput">
     <part name="body" element=
       "xsd1:TradePriceRequest"/>
   </message>
   <message name="GetLastTradePriceOutput">
     <part name="body" element="xsd1:TradePrice"/>
   </message>
   <portType name="StockQuotePortType">
     <operation name="GetLastTradePrice">
       <input message="tns:GetLastTradePriceInput"/>
       <output message="tns:GetLastTradePriceOutput"/>
     </operation>
   </portType>
     <binding name="StockQuoteSoapBinding"
       type="tns:StockQuotePortType">
       <soap:binding style="document"
         transport=
           "http://schemas.xmlsoap.org/soap/http"/>
     <operation name="GetLastTradePrice">
       <soap:operation
         soapAction=
           "http://example.com/GetLastTradePrice"/>
         <input>
           <soap:body use="literal"/>
         </input>
         <output>
           <soap:body use="literal"/>
         </output>
       </operation>
     </binding>
     <service name="StockQuoteService">
       <documentation>My first service</documentation>
       <port name="StockQuotePort" 
         binding="tns:StockQuoteBinding">
         <soap:address location=
           "http://example.com/stockquote"/>
       </port>
     </service>
  </definitions>

See Also

WSDL Specification
Overview of SOAP

About the Author

James Kao is a senior technology partner with The Middleware Company, a training and consulting company specializing in Enterprise JavaBeans, Java 2 Enterprise Edition (J2EE), and Java/XML technologies, including Web services. He has instructed developers and launched projects at companies ranging from dot-com startups to Fortune 500 enterprises.

up arrowBack to top