Part 2 – How to Test a Web Service – Its all about the WSDL


How to test a WebService – WSDL
If you are following along and have read Part One- How to Create a Web Service of this series, you should now have a working web service.

Its Automatic

We’re now going to take a look at what is WSDL is. A WSDL is an XML document that describes the methods, method parameters, namespace and handling URL for a web service. WSDLs, along with some other forms of documentation, are generated automatically whenever an HTTP-GET request is received by an .asmx file. For an example, navigate to:


This should bring up an HTML page that describes the methods of the DEMOAddNumbers web service along with some other info. Clicking on the link for the AddThis method from this page will bring up another HTML page that allows you to test the operations of the service. Pretty cool, huh?!? And now, let’s take a look at the actual WSDL.

Looking at a WSDL

For our web service, enter the following URL into your browser:


The WSDL for our web service (DEMOAddNumbers) should appear. Notice, once again, that we didn’t do anything special to generate the WSDL — it was created for us automatically. As you can see, a WSDL document is really just an XML document that contains information about a web service.

The four main sections of a WSDL

A WSDL is broken up into four main sections: elements types, messages, portType and binding.

types element – Is the data types that are used by the web services.
Notice how the information in the WSDL matches the code in our web services.

message element – This section describes the messages used by the web service and defines the data elements of an operation:

<wsdl:message name="AddThisSoapIn">
  <wsdl:part name="parameters" element="tns:AddThis" /> 
<wsdl:message name="AddThisSoapOut">
  <wsdl:part name="parameters" element="tns:AddThisResponse" /> 
 <wsdl:message name="AddThisHttpGetIn">
  <wsdl:part name="x" type="s:string" /> 
  <wsdl:part name="y" type="s:string" /> 
 <wsdl:message name="AddThisHttpGetOut">
  <wsdl:part name="Body" element="tns:int" /> 
<wsdl:message name="AddThisHttpPostIn">
  <wsdl:part name="x" type="s:string" /> 
  <wsdl:part name="y" type="s:string" /> 
- <wsdl:message name="AddThisHttpPostOut">
  <wsdl:part name="Body" element="tns:int" /> 

– the binding element describes the communication protocols used by the web service:

<wsdl:binding name="DEMOAddNumbersSoap" type="tns:DEMOAddNumbersSoap">
<wsdl:binding name="DEMOAddNumbersSoap12" type="tns:DEMOAddNumbersSoap">
<wsdl:binding name="DEMOAddNumbersHttpGet" type="tns:DEMOAddNumbersHttpGet">
<wsdl:binding name="DEMOAddNumbersHttpPost" type="tns:DEMOAddNumbersHttpPost">

portType element – The fourth element, portType, is generally considered to be the most important element, because it describes the web services and all the operations that can be performed, as well as all the messages of the service:

<wsdl:portType name="DEMOAddNumbersSoap">
 <wsdl:operation name="AddThis">
  <wsdl:input message="tns:AddThisSoapIn" /> 
  <wsdl:output message="tns:AddThisSoapOut" /> 
<wsdl:portType name="DEMOAddNumbersHttpGet">
 <wsdl:operation name="AddThis">
  <wsdl:input message="tns:AddThisHttpGetIn" /> 
  <wsdl:output message="tns:AddThisHttpGetOut" /> 
<wsdl:portType name="DEMOAddNumbersHttpPost">
<wsdl:operation name="AddThis">
  <wsdl:input message="tns:AddThisHttpPostIn" /> 
  <wsdl:output message="tns:AddThisHttpPostOut" /> 

In the section above, the portType element defines DEMOAddNumbersSoap, DEMOAddNumbersHttpGet and DEMOAddNumbersSoapPost as the name of the ports, and “AddThis” as the name of the operation. Also notice that the ports are a Request-Response operation, meaning that our web service can receive a request and will return a response. For example:

Request a request called AddThisHttpGetIn
wsdl:input message=”tns:AddThisHttpGetIn”
Return a response called AddThisHttpGetIn
wsdl:output message=”tns:AddThisHttpGetOut”

Look for my next post Part 3 – How to Test a Web Service: Response & Requests
, in which I will describe the process for sending and receiving a request from a web service using a test tool.

What is WSDL | WSDL - February 27, 2016

[…] Part 2 – How to Test a Web Service – Its all about the WSDL […]

Devapp - September 14, 2017

You can try a free mobile app to test rest api on the go. It’s simple and easy to use:

Click here to add a comment

Leave a comment: