SOAP Web Service-Introduction and WSDL Creation

Kevinnjagi
6 min readJan 15, 2024

--

Webservice -> A standardized medium to propagate communication between the client and server applications on the World Wide Web.

A SOAP web service uses WSDL (Web service description language).

WSDL

It is XML standard document used to describe a web service. This description is required so that client applications are able to understand what a web service actually does.

SOAP (Simple Object Access Protocol)

It is xml based messaging protocol for exchanging information among computers. SOAP is an application of XML specification.

SOAP is basically an XML way of defining what information is sent and how.

A SOAP message is ordinary XML document containing the following elements:

Envelope: Defines the start and end of the message. It is a mandatory element.

Header: Contains optional attributes used while processing the message. It is an optional element.

Body: Contains XML data comprising of the message which is being sent. It is a mandatory element.

Fault: An optional fault element that provides information about errors that occur while processing the message.

A sample SOAP message is shown below:

<?xml version=”1.0" encoding=”UTF-8"?>
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/" xmlns:web=”http://www.example.com/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:HelloRequest>
<web:Name>John Doe</web:Name>
</web:HelloRequest>
</soapenv:Body>
</soapenv:Envelope>

For this message, i.e. where all these elements are present, we need a WSDL file under which everything will be defined. From WSDL, this SOAP message comes out. How my web service will be accessed, what are the requests and responses… Everything will be contained in the WSDL.

<?xml version=”1.0" encoding=”UTF-8"?>
<wsdl:definitions
xmlns:wsdl=”
http://schemas.xmlsoap.org/wsdl/"
xmlns:soap=”
http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns=”
http://www.example.com/webservice"
targetNamespace=”
http://www.example.com/webservice">

<! — Types section defines the data types used in the messages →
<wsdl:types>
<xs:schema xmlns:xs=”
http://www.w3.org/2001/XMLSchema" targetNamespace=”http://www.example.com/webservice">
<xs:element name=”HelloRequest”>
<xs:complexType>
<xs:sequence>
<xs:element name=”Name” type=”xs:string”/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>

<! — Message definitions →
<wsdl:message name=”HelloRequestMessage”>
<wsdl:part name=”parameters” element=”tns:HelloRequest”/>
</wsdl:message>

<! — PortType defines the operations that can be performed →
<wsdl:portType name=”HelloPortType”>
<wsdl:operation name=”HelloOperation”>
<wsdl:input message=”tns:HelloRequestMessage”/>
</wsdl:operation>
</wsdl:portType>

<! — Binding section specifies how the operations are bound to a protocol →
<wsdl:binding name=”HelloBinding” type=”tns:HelloPortType”>
<soap:binding style=”document” transport=”
http://schemas.xmlsoap.org/soap/http”/>
<wsdl:operation name=”HelloOperation”>
<soap:operation soapAction=””/>
<wsdl:input>
<soap:body use=”literal”/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>

<! — Service section →
<wsdl:service name=”HelloService”>
<wsdl:port name=”HelloPort” binding=”tns:HelloBinding”>
<soap:address location=”
http://www.example.com/webservice"/>
</wsdl:port>
</wsdl:service>

</wsdl:definitions>

From this WSDL, we can know about our SOAP message.

We will use a tool called SoapUI to test our webservice. If we import this WSDL file, we will see our SOAP message. Let’s open it.

File>New SOAP Project>Browse and select a WSDL file.

When we click on Request 1, we see a soap message.

If we hit on the green play icon, we’ll get a response.

A response is also defined in WSDL. Just right click on operation…

Choose Add to MockService.

If we send the request to the webservice, then I will get some message as a reply. Everything is defined in a WSDL.

Why WSDL?

It is written in plain XML so that it can be read by any programming language.

General structure of a WSDL file

Types: Use to define all the complex data types which will be used to define the type of data in the message exchanged between client and web service.

Messages: This tag is used to define all the message which is exchanged between client and server. These messages explain the input and output operations which can be performed by the web service.

PortType : Tag is used to encapsulate every input and output message into one logical operation.

Binding: Used to bind the operation to a particular PortType. When a client application calls the relevant port type, it will then be able to access all the operations bound to particular port type.

Service: Tells the client how a web service can be consumed. It basically can tell the address (URL) of a web service so that client can know where a web service is located.

All the above tags are enclosed in an element called <definitions>, which is basically a root element responsible for defining name of web service and declares multiple name spaces.

Creating a WSDL in IBM ACE

Start by creating a Message set.

Right click on messageSet.mset and chose Other>Definition File

One thing you have to ensure, go to Windos>Preferences>Message Set and make sure the box is ticked.

Now, let’s add types. In this case, we’ll add complex types. Also, add elements and attributes

For example in AddEmpDetailsRequest, in that, some elements are present. We need to select all the elements required in that complex type.

Right click on the complex type and choose Add Element Reference.

We have added all the elements of AddCustomerRequest.

For AddCustomerResponse, we’ll just add one element.

In GetCustomerRequest, we will use only customer ID which will help us get everything.

In GetCustomerResponse, we need every detail of our customer.

Right click on each (GetCustomerRequest etc) and click add message from global type.

Click save, then, right click on our .mxsd file and select generate wsdl file.

Select:

  1. Generate a new WSDL definition from existing message definitions.
  2. Create in a workspace directory; select your file.
  3. Generate a single WSDL file with all XML schema inclined.
add operations

Click Finish and our WSDL is created.

To locate where it has been saved, right click on it and select properties.

Now let’s import it into our SoapUI.

Here is our AddCustomerRequest.

To see the response, right click on AddCustomer operation and Add to mockservice.

This is as a result of;

As for GetCustomerRequest, we only have CustomerID.

Let’s check the response by adding a mockservice.

The response contains all these services.

So when creating my web service using this WSDL, in order to test it, we will make use of this SoapUI.

--

--