Join Wallarm at GITEX Global 2024: Dubai
Join Wallarm at GITEX Global 2024: Dubai
Join Wallarm at GITEX Global 2024: Dubai
Join Wallarm at GITEX Global 2024: Dubai
Join Wallarm at GITEX Global 2024: Dubai
Join Wallarm at GITEX Global 2024: Dubai
Close
Privacy settings
We use cookies and similar technologies that are necessary to run the website. Additional cookies are only used with your consent. You can consent to our use of cookies by clicking on Agree. For more information on which data is collected and how it is shared with our partners please read our privacy and cookie policy: Cookie policy, Privacy policy
We use cookies to access, analyse and store information such as the characteristics of your device as well as certain personal data (IP addresses, navigation usage, geolocation data or unique identifiers). The processing of your data serves various purposes: Analytics cookies allow us to analyse our performance to offer you a better online experience and evaluate the efficiency of our campaigns. Personalisation cookies give you access to a customised experience of our website with usage-based offers and support. Finally, Advertising cookies are placed by third-party companies processing your data to create audiences lists to deliver targeted ads on social media and the internet. You may freely give, refuse or withdraw your consent at any time using the link provided at the bottom of each page.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
/
/
API Security

What is Web Services Description Language (WSDL)?

Guide With Document Format and Example

Introduction

WSDL is something that anyone involved in every web service will be familiar with adequately. Used as a means for explaining the web services, WSDL is the best pal for SOAP and REST.

In this post, we are trying to bring everything crucial related to WSDL with some real-time document examples. So, if you have anything to do with web services, pay attention to what we’re going to state next.  

What is Web Services Description Language (WSDL)?

What is WSDL?

WSDL is a means for explaining the key functions offered by a said web service. It’s an interface description language that utilizes XML syntax and formatting. 

It presents a highly machine-readable explanation of factors like how that particular web service is called for, what parameters are required for that service, and what sort of data structures are returned by it. Both the abstract as well as concrete web service elements are elaborated extensively with WSDL. 

Seeing the kind of similarities it shares with the type signature, it’s often considered as its synonym.  

Here are some of the key facts about WSDL (Web Services Description Language): 

Type- XML-based interface description language 

Existing Version- WSDL 2.0. 

Developed by- World Wide Web Consortium 

Used Technology- Extensible Markup Language (XML)

Used by- UDDI  

Looks like your basics about WSDL are clear now. So, let’s dig into the history to know it a little better! 

WSDL came into being in 2000 when the three IT giants, Ariba, IBM, and Microsoft, joined hands. The purpose behind its invention was to have an easy way to explain the existing SOAP toolkit. To design WSDL, two key service description languages, SDL and NASSL, were combined.  

The first version was named WSDL 1.0. After certain minor changes, the version WSDL 1.1 was accepted as the standard form of WSDL in 2001. 

By the time world reached in 2003, another WSDL version, version WSDL 1.2, was present at W3C in. W3C suggested that the latest version, WSDL 1.2, is much easier to work with and grants more freedom to developers as compared to WSDL 1.1.  

Much later, in 2007, WSDL 1.2 became the WSDL 2.0 version and secured a place in the W3C recommendation. However, the majority of third-party service providers kept on offering support only for WSDL 1.1 until very recently. 

Speaking of changes between the two versions, WSDL 2.0 no longer has message constructs, ports are known as endpoints, PortTypes become interfaces, and there is no overloading support for the operator. Also, a wide range of semantics was in the description language. 

Getting Familiar with the Key Part: WSDL Document Structure 

A typical WSDL document is what any end-user has to use to define the targeted web service. So, having an in-depth understanding of its elements is crucial for you to gain. 

WSDL files contain the location details of the web services alongside the process related to these web services. It comprises information about SOAP messages shared and the acknowledgments exchanged. 

On the surface, the WSDL document can look too clumsy and confusing as assorted web service-related data is mentioned in it. But, that data is later used by other client applications too. 

To put it precisely, WSDL is very similar to the real-life postcard, containing the address of a web service comprising major functionalities that might need to be delivered on the client’s request.

Structure:

<wsdl:definitions ...>
  <wsdl:types>
    ...
  </wsdl:types>
   types 2
    ...
  <wsdl:message ...>
    ...
  </wsdl:message>
  message 2
    ...

  <wsdl:portType ...>
    <wsdl:operation ...>
     input
     output
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding ...>
    operation 1
    operation 2
    ...
  </wsdl:binding>

  <wsdl:service ...>
    port 1
    port 2
    ...
  </wsdl:service>

</wsdl:definitions>
WSDL Elements

WSDL Elements with Syntax and Examples

A WSDL document needs different sorts of elements to explain such crucial details about a web service. These are:

Element #1 - Definitions 

Holding a web service’s name, you may call it the crucial-most part of WSDL. Initialized at the top of a WSDL document, it states various namespaces with their respective service elements. 

Being the root, it is closed when the service description ends.

Some namespaces like schema, soap, and wsdl are recognized by most of the commonly-used parsers by default while others need to be defined.

The syntax is: 

wsdl:definitions
<wsdl:definitions name="name_to_be_specified"
  targetNamespace="target_uri"
  xmlns:tns="target_uri"
  xmlns:wsdl="wsdl_uri"
  xmlns:xxxx="respective_uri" ...>
  ...
</wsdl:definitions>

Here, the URI for the target namespace must be the same as the one being assigned a prefix to.

The variable 'name' holds the WSDL document's name.

xmlns:wsdl is used to assign a namespace prefix for elements belonging to the core WSDL while xmls:xxxx assigns a namespace prefix for elements that are imported from diverse languages but being used as WSDL extensions.

Example:

<wsdl:definitions name="rootEXAMPLE"
  targetNamespace="http://www.example.com/wsdl_example_service/"
  xmlns:tns="http://www.example.com/wsdl_example_service/"
  xmlns:wsdl="http://www.example.com/wsdl"
  xmlns:soap="http://www.example.com/soap" ...>
  ...
</wsdl:definitions>

Element #2 - Data Types 

It explains what type of data is exchanged in messages. It is crucial as it allows precise handling of the data types at client’s end. At the same type, it also helps in the correct processing of web service.

Syntax:

<wsdl:types>
  ... plug elements from different languages that you’d imported for extensibility...
</wsdl:types>

Example: Let’s define EntReq and ExitRes data types:

<wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://www.example.com/wsdl_example_service/">
      <xsd:element name="EntReq" type="xsd:string"/>
      <xsd:element name="ExitRes" type="xsd:string"/>
    </xsd:schema>
</wsdl:types>

Element #3 - Message

In general, the message is all about performing an information exchange. In the case of WSDL, this client-server communication is regarding the web service in question. 

The message element is commonly used to state key details of the outputs and inputs operations. It can be displayed like a mapped argument or a document. 

Syntax:

<wsdl:message name="messageTKN1">
<wsdl:part name="messageTKN1" element="q1"/>
...
</wsdl:message>

OR

<wsdl:message name="messageTKN1">
<wsdl:part name="messageTKN1" type="q2"/>
...
</wsdl:message>

Here, the message token’s name is messageTKN1 while the reference name for it is messageTKN2. The ‘element’ or ‘type’ indicates the message data type for this namespace.

Example:

<wsdl:message name="IP_msg">
    <wsdl:part name="IP_part" element="hy:EntReq"/>
</wsdl:message>

Element #4 - Operation  

It carries a series of message operations. For instance: message queue, business process, and name-conventions for message(s), etc.

There are 4 operation types you can use in WSDL documents:

  1. One-way, where only an input is sent.
  2. Notification, where only the response is received.
  3. Solicit-response, where an input is given to revert to a notification/output.
  4. Request-response, where an output is received for the input message given.

Syntax: A typical request-response operation will have syntax similar to:

<wsdl:operation name="namespace_tkn1" parameterOrder="namespace_tkn">
  <wsdl:input name="namespace_tkn2" message="q2"/>
  <wsdl:output name="namespace_tkn3" message="q3"/>
  ...
</wsdl:operation>

Example:

<wsdl:operation name="GetEmpName">
  <wsdl:input message="tns:GetEmpNameIP"/>
  <wsdl:output message="tns:GetEmpNameOP"/>
</wsdl:operation>

Element #5 - Port type

It is used to turn all kinds of inputs and outs into reasonable operations. It includes a crisp operation set used to explain the binding operations. As this element is used in abstract form, mapping it to assorted transports is easy. 

Syntax:

<wsdl:portType name="Name_of_the_port_type">
<wsdl:operation name="PT_1">
  <wsdl:input name="IP1" message="soap:IP1msg"/>
  <wsdl:output name="OP1" message="soap:OP1msg"/>
</wsdl:operation>
<wsdl:operation name="PT_2">
  ...
</wsdl:operation>
</wsdl:operation>
<wsdl:operation name="PT_3">
  ...
</wsdl:operation>
  ...
</wsdl:portType>

Example:

<wsdl:portType name="PT_1">
<wsdl:operation name="GetEmpName">
  <wsdl:input message="tns:GetEmpNameIP"/>
  <wsdl:output message="tns:GetEmpNameOP"/>
</wsdl:operation>
</wsdl:portType>

Element #6 - Binding 

Binding is what WSDL documents used as the basic protocol and data format to define the operations and messages for a specific port type. It is mainly used when the client application needs a relevant port type. 

Syntax:

<wsdl:binding name="EmpSOAPbinding" type="tns:EmpPort">
    <soap:binding style="document" transport="soap_uri"/>
    <wsdl:operation name="OP1">
      <soap:operation soapAction="URI1/>
      <wsdl:input>
        <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

Example:

<wsdl:binding name="EmpSOAPbinding" type="tns:EmpPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/envelope"/>
    <wsdl:operation name="GetEmp">
      <soap:operation soapAction="http://example.com/GetEmp"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

Element #7 - Port 

Port refers to the binding combined with the network address. Its purpose is to provide the service communication address.

Syntax:

<wsdl:port name="ServicePort" binding="tns:ServiceSoapBinding">
  <soap:address location="http://example.com/service_location"/>
</wsdl:port>

Example:

<wsdl:port name="EmpPort" binding="tns:EmpSoapBinding">
  <soap:address location="http://example.com/emloyee"/>
</wsdl:port>

Element #8 - Service 

Service refers to web service and the collection of all the end-points used for defining the service definition. It may comprise a documentation element and multiple port elements.

Syntax:

<wsdl:service name="NamespaceTKN1">
    <wsdl:documentation>My first service</wsdl:documentation>
    <wsdl:port name="EmpPort" binding="tns:EmpSoapBinding">
      <soap:address location="http://example.com/emloyee"/>
    </wsdl:port>
</wsdl:service>

Example:

<wsdl:service name="NamespaceEMP1">
<wsdl:documentation>Employee Document</wsdl:documentation>
<wsdl:port name="NamespaceEMP2" binding="q">
... plug imported elements from different languages for extensibility...
</wsdl:port>
</wsdl:service>

 In addition to the above-mentioned key WSDL elements, there are two more utilities you might want to hear about:  


  • The first one is the document commonly used to hand over easy-to-read documents. These documents are human-readable and can be a part of any other WSDL element.  
  • The second utility WSDL element is imported and is used to bring any kind of other WSDL document or XML Schemas as per the need of the part. 

  

An Example of WSDL 

<wsdl:definitions name="rootEXAMPLE"
    targetNamespace="http://www.example.com/wsdl_example_service/"
    xmlns:tns="http://www.example.com/wsdl_example_service/"
    xmlns:wsdl="http://www.example.com/wsdl"
    xmlns:soap="http://www.example.com/soap" ...>
  <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://www.example.com/wsdl_example_service/">
      <xsd:element name="EntReq" type="xsd:string"/>
      <xsd:element name="ExitRes" type="xsd:string"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="messageTKN1">
    <wsdl:part name="messageTKN1" type="q2"/>
    ...
  </wsdl:message>

  <wsdl:portType name="PT_1">
    <wsdl:operation name="GetEmpName">
      <wsdl:input message="tns:GetEmpNameIP"/>
      <wsdl:output message="tns:GetEmpNameOP"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="EmpSOAPbinding" type="tns:EmpPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/envelope"/>
    <wsdl:operation name="GetEmp">
      <soap:operation soapAction="http://example.com/GetEmp"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="NamespaceTKN1">
   <wsdl:documentation>My first service</wsdl:documentation>
    <wsdl:port name="EmpPort" binding="tns:EmpSoapBinding">
      <soap:address location="http://example.com/emloyee"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>
use of wsdl

SOAP Binding

We have already got familiar with WSDL binding and know that it is used to explain the process using which a web service is linked with a message protocol. Most commonly, the at-work messaging protocol is SOAP messaging protocol

So, SOAP binding is another term that one used to get familiar with. In general, a WSDL SOAP binding is a Remote Procedure Call (RPC) style based binding. In certain cases, it is also the document style binding. It can have an encoded use or a literal use.

Those who are using WSDL 1.1 will be able to enjoy an in-built extension to process SOAP 1.1 and makes explaining the SOAP specifics easier than ever. The key SOAP specifics that can be explained easily with that in-build extension are SOAP encoding styles, SOAP headers, and SOAPAction HTTP header. 

The key SOAP binding extension elements are explained below: 

soap: binding

With the help of this element, one will be able to understand that binding is possible via SOAP. There are certain key attributes of this element with distinct meanings. For instance, the style attribute of this element refers to the SOAP message format while the rpc style value denotes the RPC format. With the transport attribute, one can find out about the transit of the SOAP messages.

soap:operation

This element is here to explain the specific operation binding required for SOAP implementation. It includes the soapAction attribute to explain the SOAPAction HTTP header service identification. 

soap:body 

Using this SOAP binding element, one is capable of explaining the input and output message details.

 

Summary

WSDL is a key description language making the process of web service implementation in one particular language from another programming language easier than ever. A WSDL document defines what a service does and how it needs to be executed. Its various elements work together to better explain the web service.

FAQ

References

Subscribe for the latest news

Updated:
May 13, 2024
Learning Objectives
Subscribe for
the latest news
subscribe
Related Topics