WebService – WSDL

Describing Web Services: WSDL
  • A web service is a server application that uses HTTP to accept and return SOAP documents, where the content of the documents is specified by a WSDL document that uses embedded XML Schema markup to define data types.

 

  • The start tag for the WSDL shows all of the namespace declarations. The default namespace is the namespace for the WSDL 1.1 vocabulary itself, http://schemas.xmlsoap.org/wsdl/.
  • Technically, all of the elements in the content of definitions are optional.
  • However, most WSDL documents will contain these elements which must appear in this order and may each be repeated any number of times
    • Types element
    • Message
    • portType
    • Binding
    • Service

 

  • Types element
    • defines data types that can be used as the types of input parameters or return values later in the WSDL document.
    • The content of types is normally XML Schema markup.

 

  • Message elements
    • When a WSDL document is written, each message is intended
      • either to define an input parameter list for an operation or
      • to define the data type of the value returned by the operation.

 

  • portType element
    • There can be several portType elements in a WSDL document.
    • It defines – at an abstract level – the operations of a web service.
    • Each operation name is Unique.
    • Each operation in turn consists of an input and an output element.

 

  • Binding element.
    • Purpose – specify a way in which the operations specified abstractly in portType can be accessed remotely by a client.
    • The WSDL vocabulary allows for the possibility of a web service being implemented with an XML vocabulary other than SOAP and a communication protocol other than HTTP.

 

    • The type attribute of this element specifies the name of the portType element to which this binding applies.
    • The content of a binding element parallels that of a portType: it primarily consists of operation elements, one for each of the operation elements in the corresponding portType and having the same name.
    • The content of each operation element in a binding is a pair of input and output elements, just as there was within each operation element of a portType.
    • elements normally contain a single soap:body element that provides communication details such as whether or not the associated message should be encoded and, if so, what form of encoding should be used.

 

  • Service element
    • This provides
      • a name for the overall web service (HistoricCurrencyConverter in this example)
      • one or more port elements – each of which associates a binding with an Internet address.
    • In the case of SOAP-over-HTTP, this address is specified by including a soap:address element in the content of the port, as shown.

 


 

Example WSDL Document

 

<?xml version=”1.0″ encoding=”UTF-8″?>

<definitions     name=”HistoricCurrencyConverter”

targetNamespace=”http://tempuri.org/wsdl”

xmlns:tns=”http://tempuri.org/wsdl”

xmlns=”http://schemas.xmlsoap.org/wsdl/”

xmlns:ns2=”http://tempuri.org/types”

xmlns:xsd=”http://www.w3.org/2001/XMLSchema”

xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/”>

 

<types>

<schema          targetNamespace=”http://tempuri.org/types”

xmlns:tns=”http://tempuri.org/types”

. . .  >

<import         namespace=”http://schemas.xmlsoap.org/soap/encoding/”/>

<complexType name=”ExchangeValues”>

<sequence>

<element name=”dollars” type=”double”/>

<element name=”euros” type=”double”/>

<element name=”yen” type=”double”/>

</sequence>

</complexType>

</schema>

</types>

 

<message name=”CurCon_fromDollars”>

                    <part name=”double_1″ type=”xsd:double”/>

</message>

….

 

<portType name=”CurCon”>

<operation name=”fromDollars” parameterOrder=”double_1″>

<input message=”tns:CurCon_fromDollars”/>

<output message=”tns:CurCon_fromDollarsResponse”/>

</operation>

</portType>

 

<binding name=”CurConBinding” type=”tns:CurCon”>

<operation name=”fromDollars”>

<input>

<soap:body encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”

use=”encoded” namespace=”http://tempuri.org/wsdl”/>

</input>

 

<output>

<soap:body encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”

use=”encoded” namespace=”http://tempuri.org/wsdl”/>

</output>

 

<soap:operation soapAction=””/>

 

</operation>

. . . .

<soap:binding           transport=http://schemas.xmlsoap.org/soap/http style=”rpc”/>

</binding>

 

<service name=”HistoricCurrencyConverter”>

<port name=”CurConPort” binding=”tns:CurConBinding”>

<soap:address location=”REPLACE_WITH_ACTUAL_URL”/>

</port>

</service>

</declarations>

 


 

Example WSDL Document Elements (to easily remember)

<?xml version=”1.0″ encoding=”UTF-8″?>

<definitions     name of the webservice and namespace>

<types>       schema    information  </types>

<message name of method >       part(element name and data type)      </message>

<portType name of service >        operation, input, output        </portType>

<binding name of service, namespace type>       

( operation, input (soap body), output, soap:operation )

(soap binding)      </binding>

<service name of web service >       port, soap:address       </service>

</declarations>