WSDL Tutorial: Web Service Description Language Explained

If you work with web services, there are several different important techniques. Alongside SOAP and REST, one of these is description language WSDL. It serves to describe the functions of a web service so that other network participants can also use the services. How does the language work, what do you need the WSDL file for exactly, and what links are there to other languages?

What is WSDL?

WSDL stands for Web Service Description Language. It is a metalanguage with which web services can be comprehensively described. In turn, a web service is a service that a server provides to clients via the Internet (or another network). This takes place independently from a platform, between different systems and applications. A WSDL file is available on the server so that a client can find out about the possibilities and procedures of the web service. The details given in the file tell the client how to access the web service.

WSDL uses Extensible Markup Language (XML) or the XML schema (XSD) as its base. This means that WSDL uses XML elements.

Fact

WSDL is standardised by the World Wide Web Consortium (W3C).

Structure and properties of WSDL

WSDL uses abstract and specific descriptions to describe web services. While the abstract description refers to the functionality of the service, the specific description conveys clear facts such as the transmission protocol. The document (i.e. the WSDL file) has a hierarchical structure. Information is therefore nested.

WSDL adopts six main elements from XML:

  • types: data types
  • messages: description of the data to be transmitted
  • interface: abstract operations which describe the communication between the server and client (was still called portType in an older version of the standard)
  • binding: information about the transport protocol used
  • endpoint: information about the communication interface, usually in the form of a URI (was still called port in an older version of the standard
  • service: access points of the web service

By filling in all the elements in the file, the client gets all the information needed to use the web service. This is precisely why a web service is platform-independent, because the different systems receive the common language through the WSDL file.

WSDL: Example

The structure of a WSDL file is now described in more detail below using an example. The following code is for a web service that returns a simple "Hello World".

<?xml version="1.0"?>
<definitions name="HelloWorld"
targetNamespace="http://example.com/helloworld.wsdl"
xmlns:tns="http://example.com/helloworld.wsdl"
xmlns:xsd1="http://example.com/helloworld.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">

  <types>
    <schema targetNamespace="http://example.com/helloworld.xsd"
      xmlns="http://www.w3.org/2000/10/XMLSchema">
      <element name="HelloWorldElement">
        <complexType>
          <all>
            <element name="worldRequest" type="string"/>
          </all>
        </complexType>
      </element>
</schema>
</types>

<message name = "HelloWorldRequest">
<part name = "name" type = "xsd:string"/>
</message>

<message name = "HelloWorldResponse">
<part name = "greeting" type = "xsd:string"/>
</message>

<interface name = "HelloWorld_Interface">
<operation name = "sayHelloWorld">
<input message = "tns:HelloWorldRequest"/>
<output message = "tns:HelloWorldResponse"/>
</operation>
</interface>

<binding name = "HelloWorld_Binding" type = "tns:HelloWorld_Interface">
<soap:binding style = "rpc"
transport = "http://schemas.xmlsoap.org/soap/http"/>
<operation name = "sayHelloWorld">
<soap:operation soapAction = "sayHelloWorld"/>
<input>
<soap:body
encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
namespace = "urn:examples:helloworld"
use = "encoded"/>
</input>
<output>
<soap:body
encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
namespace = "urn:examples:helloworld"
use = "encoded"/>
</output>
</operation>
</binding>

<service name = "Hello_World">
<documentation>WSDL File for HelloWorld</documentation>
<endpoint binding = "tns:HelloWorld_Binding" name = "HelloWorld_Endpoint">
<soap:address
location = "http://www.example.com/HelloWorld/" />
</endpoint>
</service>
</definitions>

In the source code example, you can clearly see the individual components of a WSDL file. After an initial introduction, which also includes a reference to WSDL and XSD, the abstract descriptions types, messages and interface follow. The second half consists of the specific descriptions, where endpoint is incorporated in service.


We’re all in this together. At IONOS we are
#hereforyou
Coronavirus is a challenge we need to face together.
We've created special offers on key products to help
your business keep going.
3 months free
Online Shop
Be where your customers are with your own online store.