If you work with web services, there are several different important tech­niques. Alongside SOAP and REST, one of these is de­scrip­tion language WSDL. It serves to describe the functions of a web service so that other network par­ti­cipants 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 De­scrip­tion Language. It is a metalan­guage with which web services can be com­pre­hens­ively described. In turn, a web service is a service that a server provides to clients via the Internet (or another network). This takes place in­de­pend­ently from a platform, between different systems and ap­plic­a­tions. A WSDL file is available on the server so that a client can find out about the pos­sib­il­it­ies and pro­ced­ures of the web service. The details given in the file tell the client how to access the web service.

WSDL uses Ex­tens­ible Markup Language (XML) or the XML schema (XSD) as its base. This means that WSDL uses XML elements.

Fact

WSDL is stand­ard­ised by the World Wide Web Con­sor­ti­um (W3C).

Structure and prop­er­ties of WSDL

WSDL uses abstract and specific de­scrip­tions to describe web services. While the abstract de­scrip­tion refers to the func­tion­al­ity of the service, the specific de­scrip­tion conveys clear facts such as the trans­mis­sion protocol. The document (i.e. the WSDL file) has a hier­arch­ic­al structure. In­form­a­tion is therefore nested.

WSDL adopts six main elements from XML:

  • types: data types
  • messages: de­scrip­tion of the data to be trans­mit­ted
  • interface: abstract op­er­a­tions which describe the com­mu­nic­a­tion between the server and client (was still called portType in an older version of the standard)
  • binding: in­form­a­tion about the transport protocol used
  • endpoint: in­form­a­tion about the com­mu­nic­a­tion 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 in­form­a­tion needed to use the web service. This is precisely why a web service is platform-in­de­pend­ent, 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 in­di­vidu­al com­pon­ents of a WSDL file. After an initial in­tro­duc­tion, which also includes a reference to WSDL and XSD, the abstract de­scrip­tions types, messages and interface follow. The second half consists of the specific de­scrip­tions, where endpoint is in­cor­por­ated in service.

Go to Main Menu