8. SOAP and WSDL

8.1. WSDL

Web Services Description Language

is an XML-based interface description language that is used for describing the functionality offered by a web service. The acronym is also used for any specific WSDL description of a web service (also referred to as a WSDL file), which provides a machine-readable description of how the service can be called, what parameters it expects, and what data structures it returns. Therefore, its purpose is roughly similar to that of a type signature in a programming language [Wik19j].

Web Application Description Language

Machine-readable XML description of HTTP-based web services. WADL models the resources provided by a service and the relationships between them.[1] WADL is intended to simplify the reuse of web services that are based on the existing HTTP architecture of the Web. It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser.

WADL was submitted to the World Wide Web Consortium by Sun Microsystems on 31 August 2009, but the consortium has no current plans to standardize it. WADL is the REST equivalent of SOAP's Web Services Description Language (WSDL), which can also be used to describe REST web services.

8.1.1. Main Structure


  data type definitions........

  definition of the data being communicated....

  set of operations......

  protocol and data format specification....


8.1.2. Example

  • In this example the <portType> element defines "glossaryTerms" as the name of a port, and "getTerm" as the name of an operation.

  • The "getTerm" operation has an input message called "getTermRequest" and an output message called "getTermResponse".

  • The <message> elements define the parts of each message and the associated data types.

<message name="getTermRequest">
  <part name="term" type="xs:string"/>

<message name="getTermResponse">
  <part name="value" type="xs:string"/>

<portType name="glossaryTerms">
  <operation name="getTerm">
    <input message="getTermRequest"/>
    <output message="getTermResponse"/>
</portType> The <portType> Element

  • The <portType> element defines a web service, the operations that can be performed, and the messages that are involved.

  • The request-response type is the most common operation type, but WSDL defines four types:




The operation can receive a message but will not return a response


The operation can receive a request and will return a response


The operation can send a request and will wait for a response


The operation can send a message but will not wait for a response

8.1.3. WSDL One-Way Operation

<message name="newTermValues">
  <part name="term" type="xs:string"/>
  <part name="value" type="xs:string"/>

<portType name="glossaryTerms">
  <operation name="setTerm">
    <input name="newTerm" message="newTermValues"/>
</portType >

8.1.4. WSDL Request-Response Operation

<message name="getTermRequest">
  <part name="term" type="xs:string"/>

<message name="getTermResponse">
  <part name="value" type="xs:string"/>

<portType name="glossaryTerms">
  <operation name="getTerm">
    <input message="getTermRequest"/>
    <output message="getTermResponse"/>

8.1.5. WSDL Binding to SOAP

<message name="getTermRequest">
  <part name="term" type="xs:string"/>

<message name="getTermResponse">
  <part name="value" type="xs:string"/>

<portType name="glossaryTerms">
  <operation name="getTerm">
    <input message="getTermRequest"/>
    <output message="getTermResponse"/>

<binding type="glossaryTerms" name="b1">
   <soap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
     <soap:operation soapAction="http://example.com/getTerm"/>
     <input><soap:body use="literal"/></input>
     <output><soap:body use="literal"/></output>

8.1.6. Example WSDL file

<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://www.w3.org/ns/wsdl"

    This is a sample WSDL 2.0 document.

<!-- Abstract type -->
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

         <xs:element name="request"> ... </xs:element>
         <xs:element name="response"> ... </xs:element>

<!-- Abstract interfaces -->
   <interface name="Interface1">
      <fault name="Error1" element="tns:response"/>
      <operation name="Get" pattern="http://www.w3.org/ns/wsdl/in-out">
         <input messageLabel="In" element="tns:request"/>
         <output messageLabel="Out" element="tns:response"/>

<!-- Concrete Binding Over HTTP -->
   <binding name="HttpBinding" interface="tns:Interface1"
      <operation ref="tns:Get" whttp:method="GET"/>

<!-- Concrete Binding with SOAP-->
   <binding name="SoapBinding" interface="tns:Interface1"
      <operation ref="tns:Get" />

<!-- Web Service offering endpoints for both bindings-->
   <service name="Service1" interface="tns:Interface1">
      <endpoint name="HttpEndpoint"
      <endpoint name="SoapEndpoint"

8.1.7. Example WADL

<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd"
 xmlns:tns="urn:yahoo:yn" xmlns:yn="urn:yahoo:yn" xmlns:ya="urn:yahoo:api"
    <include href="NewsSearchResponse.xsd"/>
    <include href="Error.xsd"/>

  <resources base="http://api.search.yahoo.com/NewsSearchService/V1/">
    <resource path="newsSearch">
      <method name="GET" id="search">
          <param name="appid" type="xsd:string" style="query" required="true"/>
          <param name="query" type="xsd:string" style="query" required="true"/>
          <param name="type" style="query" default="all">
            <option value="all"/>
            <option value="any"/>
            <option value="phrase"/>
          <param name="results" style="query" type="xsd:int" default="10"/>
          <param name="start" style="query" type="xsd:int" default="1"/>
          <param name="sort" style="query" default="rank">
            <option value="rank"/>
            <option value="date"/>
          <param name="language" style="query" type="xsd:string"/>
        <response status="200">
          <representation mediaType="application/xml" element="yn:ResultSet"/>
        <response status="400">
          <representation mediaType="application/xml" element="ya:Error"/>

8.2. suds

from suds.client import Client

client = Client("http://example.com/foo.wsdl")
from suds.client import Client

# The service URL
soap_url = 'http://myapp.example.notreal/path/to/soap'

# The WSDL URL, we wont' use this but just illustrating for example. This
# would be the file you download to your system and save as wsdl_file
wsdl_url = 'http://myapp.example.notreal/path/to/soap?wsdl'

# The full path to the downloaded WSDL file on your local system
wsdl_file = '/path/to/myapp.wsdl'
wsdl_url = 'file://' + wsdl_file # Override original wsdl_url

client = Client(url=wsdl_url, location=soap_url)

8.3. zeep

  • maintained

from zeep import Client

client = Client('http://www.webservicex.net/ConvertSpeed.asmx?WSDL')
result = client.service.ConvertSpeed(100, 'kilometersPerhour', 'milesPerhour')

assert result == 62.137
import zeep

wsdl = 'http://www.soapclient.com/xml/soapresponder.wsdl'
client = zeep.Client(wsdl=wsdl)
print(client.service.Method1('Zeep', 'is cool'))