WSDL is short for Web Service Description Language. WSDL is used to describe the interface of a web service. A WSDL file is an XML file. It contains set of definitions to describe a web service. A WSDL document describes a web service using these major elements:

definition/description  – The definition/description element is the root element of the WSDL 1.1/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.

portType /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.

message – an abstract definition of the data, in the form of a message presented either as an entire document or as arguments to be mapped to a method invocation.

port / endPoint: a combination of a binding and a network address, providing the target address of the service communication.

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.

Following are the differences between WSDL1.1 and WSDL 2.0 :
WSDL 1.1 WSDL 2.0
<definitions> <description>
<portType> <interface>
<port> <endpoint>
<message> <message> is removed and defined inside <operation>


Lets take an example. Create a dynamic web prject and add fowwing class:


import javax.jws.WebService;

public class Calculator {

 public long multiply(int x, int y){

 return x*y;


Now deploy this project in jboss. The wsdl generated by the serer looks like this :

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:xsd=""
 xmlns:wsdl="" xmlns:tns="http://ws.soap.mynotes/"
 xmlns:soap="" xmlns:ns1=""
 name="CalculatorService" targetNamespace="http://ws.soap.mynotes/">
 <xs:schema xmlns:xs=""
 xmlns:tns="http://ws.soap.mynotes/" elementFormDefault="unqualified"
 targetNamespace="http://ws.soap.mynotes/" version="1.0">

<xs:element name="multiply" type="tns:multiply" />

<xs:element name="multiplyResponse" type="tns:multiplyResponse" />

<xs:complexType name="multiply">
 <xs:element name="arg0" type="xs:int" />
 <xs:element name="arg1" type="xs:int" />

<xs:complexType name="multiplyResponse">
 <xs:element name="return" type="xs:long" />

 <wsdl:message name="multiplyResponse">
 <wsdl:part element="tns:multiplyResponse" name="parameters">
 <wsdl:message name="multiply">
 <wsdl:part element="tns:multiply" name="parameters">
 <wsdl:portType name="Calculator">
 <wsdl:operation name="multiply">
 <wsdl:input message="tns:multiply" name="multiply">
 <wsdl:output message="tns:multiplyResponse" name="multiplyResponse">
 <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:Calculator">
 <soap:binding style="document"
 transport="" />
 <wsdl:operation name="multiply">
 <soap:operation soapAction="" style="document" />
 <wsdl:input name="multiply">
 <soap:body use="literal" />
 <wsdl:output name="multiplyResponse">
 <soap:body use="literal" />
 <wsdl:service name="CalculatorService">
 <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
 <soap:address location="http://localhost:8080/MyNotes_WebService/Calculator" />

Lets take each element one by one starting from the bottom.

At the end we have an element called wsdl:service element which is you service name. Notice it has added the word Service at the end to you WebService class which was Calculator. This contains a port element named CalculatorPort which is binded with tns:CalculatorServiceSoapBinding.  The port contains a location url.

Then comes the wsdl:binding element. This contains the soap:binding which tells the transport mechanism which is here soap over http. It also contains some details about the operations and the input and output parameters. Note that this is from soap perspective and do not tell what type the data are. The wsdl:binding has a type tns:Calculator. 

The wsdl:portType has a wsdl:operation called multiply which has wsdl:input and wsdl:output elements. These are messages which refer to their respective message elements i.e tns:multiply (input) and tns:multiplyResponse(output).

The wsdl:message inturn refer to the wsdl:types which described these using XML Schema by default.

Till now we have been creating java implementation first and then creating the wsdl out of it. This approach is called bottom up approach.

There are two approaches in implementing a web service and they are bottom-up and top-down:

  • Top Down Approach – means you start with a WSDL and then create all the necessary scaffolding in Java all the way down.
  • Bottom Up Approach – means you start with a Java method, and generate the WSDL from it.

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

%d bloggers like this: