WSDL Basics

What and Why WSDL

WSDL is a descriptor for Web Service that is XML formatted. Like any J2EE descriptors, it basically describes the Web Service. Web Service is described as a set of endpoints (ports) which would have 2 parts – Abstract definition and Concrete binding (Will dive onto that later).


The WSDL is basically the contract between the client and implementation. Everything that are defined and exposed has a definition inside the WSDL file.

Why WSDL? – Enables automation of communication details between communicating partners. Machines can read XML/WSDL documents and able to invoke the defined service in WSDL. 3rd part can also verify if the communication conforms to WSDL standards.

WSDL Document Structure


<wsdl:definitions xmlns:wsdl=""                   targetNamespace="your name space here"                   xmlns:tns="your name space here"                   xmlns:soapbind="">

        <xs:schema targetNamespace="your namespace here" xmlns:xsd="">

    <wsdl:message name="some operation input">
           <!--Parts here-->

    <wsdl:message name ="some operation output">
        <!--Parts here-->

    <wsdl:portType name="your type name">
        <!-- Define operations here-->

    <wsdl:binding name="your binding name" type="tns:port type name above">
        <!-- define style of transport here-->



On the sample above, the XML file uses the wsdl namespace as highlighted.

Example of WSDL document

The WSDL service above has a simple service generating strings and returning them. It will have a single operation called getSystemMessageAndReturn. It will be deployed using SOAP 1.1 over HTTP. The service takes a “string” message and responds with a message that has the “string” in it.

Nothing is much more simpler than that.

7 Elements of WSDL:

  • Types – data type definition and used to describe exchanged messages.
  • Message – abstract, typed definitions of data being exchanged
  • Operation – abstract description of an action. Refers to an input and/or output messages.
  • Port Type – Collection of operations
  • Binding – Concrete protocol and data format (encoding) for a particular Port type.
  • Port  – Defines a single communication endpoint. Endpoint address for binding. URL for HTTP, email address for SMTP.
  • Service -Aggregate set of related ports.

WSDL View of a Web Service


Web Service Invocation


Message Element

A message element can consist of one or more logical parts. It is basically the data unit of an WSDL definition.

<definitions ....>
   <message name="nmtoken">
      <part name="nmtoken" element="qname"? type="qname" ?/>

Types of Operations

There are 2 types of operations that we can define on our WSDL. One way or Two way.


The endpoint receives a message only.

<operation name="submitPurchase">
   <input message="purchase"/>


The endpoint receives a message and sends a correlated message.

<operation name="submitPurchase">
   <input message="purchase"/>
   <output message="confirmation"/>
<operation name="submitPurchase">
   <input message="purchase"/>
   <output message="confirmation"/>
   <fault message="faultMessage"/>

Importing and Authoring Style

  • When a developer creates a web service, it is important to consider reusability and maintainability.
  • It is important also to maintain a WSDL document in 3 separate parts.
    • Data Type definitions
    • Abstract definitions
    • Specific Service Bindings
  • Use import element to import necessary part of WSDL document. This makes the parts more isolated and thus, maintainable.=


You can download some WSDL examples here.

On the next blog post, we’ll be creating a Web Service from scratch and apply all what we learned from here. See you!

One thought on “WSDL Basics

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s