SoapUI - WSDL



WSDL stands for Web Services Description Language. It is a standard format for describing a web service. WSDL was developed jointly by Microsoft and IBM. WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'.

WSDL ─ A Brief History

WSDL 1.1 was submitted as a W3C Note by Ariba, IBM, and Microsoft for describing services for the W3C XML Activity on XML Protocols in March 2001.

WSDL 1.1 has not been endorsed by the World Wide Web Consortium (W3C), however it has just released a draft for version 2.0 that will be a recommendation (an official standard), and thus endorsed by the W3C.

WSDL ─ Points to Note

WSDL is an XML-based protocol for information exchange in a decentralized and distributed environment. Some of the other features of WSDL are as follows −

  • WSDL definitions describe how to access a web service and what operations it will perform.

  • It is a language for describing how to interface with XML-based services.

  • It is an integral part of Universal Description, Discovery, and Integration (UDDI), an XML-based worldwide business registry.

  • WSDL is the language that UDDI uses.

WSDL Usage

WSDL is often used in combination with SOAP and XML Schema to provide web services over the Internet. A client program connecting to a web service can read the WSDL to determine what functions are available on the server. Any special datatypes used are embedded in the WSDL file in the form of XML Schema. The client can then use SOAP to actually call one of the functions listed in the WSDL.

Understanding WSDL

WSDL breaks down the web services into three specific, identifiable elements that can be combined or reused once defined.

The three major elements of WSDL that can be defined separately are −

  • Types
  • Operations
  • Binding

A WSDL document has various elements, but they are contained within these three main elements, which can be developed as separate documents and then they can be combined or reused to form complete WSDL files.

In this tutorial, we are following CurrencyConverter WSDL: http://www.webservicex.net

Format and Elements

CurrencyConverter WSDL will look like the following −

Currency Converter

Response

Binding Elements

WSDL ─ Port Type

The <portType> element combines multiple message elements to form a complete one-way or round-trip operation. For example, a <portType> can combine one request and one response message into a single request/response operation. This is most commonly used in SOAP services. A portType can define multiple operations.

Example

Port Type
  • The portType element defines a single operation, called ConversionRate.
  • The operation consists of a single input message ConversionRateHttpPostIn.
  • The operation for Output message is ConversionRateHttpPostOut.

Patterns of Operation

WSDL supports four basic patterns of operation −

One Way

The service receives a message. The operation therefore has a single input element. The grammar for one-way operation is −

<wsdl:definitions .... >  
   <wsdl:portType .... > * 
      <wsdl:operation name = "nmtoken"> 
         <wsdl:input name = "nmtoken"? message = "qname"/> 
      </wsdl:operation> 
   </wsdl:portType > 
</wsdl:definitions> 

Request ─ Response

The service receives a message and sends a response. The operation therefore has one input element, followed by one output element. To encapsulate errors, an optional fault element can also be specified. The grammar for a request-response operation is −

<wsdl:definitions .... > 
   <wsdl:portType .... > * 
      <wsdl:operation name = "nmtoken" parameterOrder = "nmtokens"> 
         <wsdl:input name = "nmtoken"? message = "qname"/> 
         <wsdl:output name = "nmtoken"? message = "qname"/> 
         <wsdl:fault name = "nmtoken" message = "qname"/>* 
      </wsdl:operation> 
   </wsdl:portType > 
</wsdl:definitions> 

Solicit ─ Response

The service sends a message and receives a response. The operation therefore has one output element, followed by one input element. To encapsulate errors, an optional fault element can also be specified. The grammar for a solicit-response operation is −

<wsdl:definitions .... > 
   <wsdl:portType .... > * 
      <wsdl:operation name = "nmtoken" parameterOrder = "nmtokens"> 
         <wsdl:output name = "nmtoken"? message = "qname"/> 
         <wsdl:input name = "nmtoken"? message = "qname"/> 
         <wsdl:fault name = "nmtoken" message = "qname"/>* 
      </wsdl:operation> 
   </wsdl:portType > 
</wsdl:definitions> 

Notifications

The service sends a message. The operation therefore has a single output element. Following is the grammar for a notification operation −

<wsdl:definitions .... > 
   <wsdl:portType .... > * 
      <wsdl:operation name = "nmtoken"> 
         <wsdl:output name = "nmtoken"? message = "qname"/> 
      </wsdl:operation> 
   </wsdl:portType > 
</wsdl:definitions> 

WSDL ─ Binding & Service

The <binding> element provides specific details on how a portType operation will actually be transmitted over the wire.

  • The bindings can be made available via multiple transports including HTTP GET, HTTP POST, or SOAP.

  • The bindings provide concrete information on what protocol is being used to transfer portType operations.

  • The bindings provide information where the service is located.

  • For SOAP protocol, the binding is <soap:binding>, and the transport is SOAP messages on top of HTTP protocol.

  • You can specify multiple bindings for a single portType.

Binding Services

Service

The <service> element defines the ports supported by the web service. For each of the supported protocols, there is one port element. The service element is a collection of ports.

Web service clients can learn the following from the service element −

  • Where to access the service,
  • Through which port to access the web service, and
  • How the communication messages are defined.

The service element includes a documentation element to provide human-readable documentation.

<wsdl:service name = "CurrencyConvertor">
   <wsdl:port name = "CurrencyConvertorSoap" binding = "tns:CurrencyConvertorSoap">
      <soap:address location = "http://www.webservicex.net/CurrencyConvertor.asmx" />
   </wsdl:port>
   <wsdl:port name = "CurrencyConvertorSoap12"binding = "tns:CurrencyConvertorSoap12>
      <soap12:address location = "http://www.webservicex.net/CurrencyConvertor.asmx" />
   </wsdl:port>
   <wsdl:port name = "CurrencyConvertorHttpGet" binding = "tns:CurrencyConvertorHttpGet">
      <http:address location = "http://www.webservicex.net/CurrencyConvertor.asmx" />
   </wsdl:port>
   <wsdl:portname = "CurrencyConvertorHttpPost"binding = "tns:CurrencyConvertorHttpPost">
      <http:address location = "http://www.webservicex.net/CurrencyConvertor.asmx" />
   </wsdl:port> 
</wsdl:service> 
Advertisements