WSDL 2.0 - Overview

Jakob Jenkov
Last update: 2014-05-23

A WSDL file is an XML file describing the interface of a web service. A WSDL 2.0 file contains the following elements:

description The description element is the root element of the WSDL 2.0 file. All other WSDL elements are nested inside this element.
types The types element contains a specification of the data types exchanged between the client and the web service. By default these data types are described using XML Schema.
interface The interface element describes what operations the web service has, and what messages are exchanged for each operation (input / output). It also describes possible fault messages.
binding The binding element describes how the web service is accessed over the network. Typically the binding element binds the web service to the HTTP protocol.
service The service element describes where the web service can be accessed on the network. Typically the service element contains a URL to the service.
documentation The documentation element is optional and may contain a humanly readable description of the web service.
import The import element is optional and may be used to import XML Schemas or other WSDL files.

Each of these elements are explained in more detail in their own texts. See the top corner of this page for links to these texts.

Here is an outline of the required XML elements in a WSDL file:

<description>

  <types>
  </types>

  <interface>
  </interface>

  <binding>
  </binding>

  <service>
  </service>

</description>

WSDL Compared to Java Interfaces

Since WSDL describes the interface of a web service, I thought it might be useful for you to see how the XML elements in the WSDL match the declaration of a Java interface. That is what the diagram below shows. The orange boxes represent elements in the WSDL file.

WSDL compared to a Java interface.
WSDL compared to a Java interface. The orange boxes are WSDL elements.

As you can see, the Java classes (Input and Output) would be defined in the types element in WSDL. So would the exception. The method in the Java interface would be declared in an operation element inside the WSDL interface element. You'll see more examples on that in the interface text.

Full WSDL Example

Here is a full WSDL example:

<?xml version="1.0" encoding="utf-8" ?>
<description
    xmlns=           "http://www.w3.org/ns/wsdl"
    targetNamespace= "http://jenkov.com/MyService"
    xmlns:tns=       "http://jenkov.com/MyService"
    xmlns:stns =     "http://jenkov.com/MyService/schema"
    xmlns:wsoap=     "http://www.w3.org/ns/wsdl/soap"
    xmlns:soap=      "http://www.w3.org/2003/05/soap-envelope"
    xmlns:wsdlx=     "http://www.w3.org/ns/wsdl-extensions" >

  <documentation>
    This is the web service documentation.
  </documentation>

  <types>
    <xs:schema
        xmlns:xs=        "http://www.w3.org/2001/XMLSchema"
        targetNamespace= "http://jenkov.com/MyService/schema"
        xmlns=           "http://jenkov.com/MyService/schema">

      <xs:element name="latestTutorialRequest"
                     type="typeLatestTutorialRequest"/>

      <xs:complexType name="typeLatestTutorialRequest">
        <xs:sequence>
          <xs:element  name="date"   type="xs:date"/>
        </xs:sequence>
      </xs:complexType>

      <xs:element name="latestTutorialResponse" type="xs:string"/>

      <xs:element name="invalidDateError" type="xs:string"/>

    </xs:schema>
  </types>

  <interface  name = "latestTutorialInterface" >

    <fault name = "invalidDateFault"  element = "stns:invalidDateError"/>

    <operation name="latestTutorialOperation"
            pattern="http://www.w3.org/ns/wsdl/in-out"
            style="http://www.w3.org/ns/wsdl/style/iri"
            wsdlx:safe = "true">

      <input    messageLabel="In"  element="stns:latestTutorialRequest" />
      <output   messageLabel="Out" element="stns:latestTutorialResponse" />
      <outfault messageLabel="Out" ref    ="tns:invalidDateFault" />
    
    </operation>

  </interface>

  <binding name="latestTutorialSOAPBinding"
          interface="tns:latestTutorialInterface"
          type="http://www.w3.org/ns/wsdl/soap"
          wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">

    <fault ref="tns:invalidDateFault" wsoap:code="soap:Sender"/>

    <operation ref="tns:latestTutorialOperation"
      wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/>

  </binding>

  <service
       name     ="latestTutorialService"
       interface="tns:latestTutorialInterface">

     <endpoint name ="latestTutorialEndpoint"
            binding ="tns:latestTutorialSOAPBinding"
            address ="http://jenkov.com/latestTutorial"/>

  </service>

</description>

Jakob Jenkov

Featured Videos

Java Generics

Java ForkJoinPool

P2P Networks Introduction



















Close TOC
All Tutorial Trails
All Trails
Table of contents (TOC) for this tutorial trail
Trail TOC
Table of contents (TOC) for this tutorial
Page TOC
Previous tutorial in this tutorial trail
Previous
Next tutorial in this tutorial trail
Next