0
6.7kviews
Describe the significance & working of WSDL with an example.
1 Answer
2
21views

The Web Services Description Language (WSDL) is an XML-based interface definition 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 method signature in a programming language.’

WSDL Elements

A WSDL document contains the following elements:

  • Definition: It is the root element of all WSDL documents. It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here.
  • Data types: The data types to be used in the messages are in the form of XML schemas.
  • Message: It is an abstract definition of the data, in the form of a message presented either as an entire document or as arguments to be mapped to a method invocation.
  • Operation: It is the abstract definition of the operation for a message, such as naming a method, message queue, or business process, that will accept and process the message.
  • Port type: It is an abstract set of operations mapped to one or more end-points, defining the collection of operations for a binding; the collection of operations, as it is abstract, can be mapped to multiple transports through various bindings.
  • Binding: It is the concrete protocol and data formats for the operations and messages defined for a particular port type.
  • Port: It is a combination of a binding and a network address, providing the target address of the service communication.
  • Service: It is a collection of related end-points encompassing the service definitions in the file; the services map the binding to the port and include any extensibility definitions.

    In addition to these major elements, the WSDL specification also defines the following utility elements:

  • Documentation: This element is used to provide human-readable documentation and can be included inside any other WSDL element.

  • Import: This element is used to import other WSDL documents or XML Schemas.

Example (WSDL File):

<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="https://www.w3.org/ns/wsdl" 
             xmlns:tns="https://www.tmsws.com/wsdl20sample" 
             xmlns:whttp="https://schemas.xmlsoap.org/wsdl/http/"
             xmlns:wsoap="https://schemas.xmlsoap.org/wsdl/soap/"
             targetNamespace="https://www.tmsws.com/wsdl20sample">

<documentation>
    This is a sample WSDL 2.0 document. 
</documentation>

<!-- Abstract type -->
   <types>
      <xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema"
                xmlns="https://www.tmsws.com/wsdl20sample"
                targetNamespace="https://www.example.com/wsdl20sample">

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

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

<!-- Concrete Binding Over HTTP -->
   <binding name="HttpBinding" interface="tns:Interface1" 
            type="https://www.w3.org/ns/wsdl/http">
      <operation ref="tns:Get" whttp:method="GET"/>
   </binding>

<!-- Concrete Binding with SOAP-->
   <binding name="SoapBinding" interface="tns:Interface1" 
            type="https://www.w3.org/ns/wsdl/soap" 
            wsoap:protocol="https://www.w3.org/2003/05/soap/bindings/HTTP/"
            wsoap:mepDefault="https://www.w3.org/2003/05/soap/mep/request-response">
      <operation ref="tns:Get" />
   </binding>

<!-- Web Service offering endpoints for both bindings-->
   <service name="Service1" interface="tns:Interface1">
      <endpoint name="HttpEndpoint" 
                binding="tns:HttpBinding" 
                address="https://www.example.com/rest/"/>
      <endpoint name="SoapEndpoint" 
                binding="tns:SoapBinding" 
                address="https://www.example.com/soap/"/>
   </service>
</description>
Please log in to add an answer.