Web Service Description Language (WSDL)


WSDL which is xml based contains the information about the web service. Typically WSDL is generated by the server in which the service is held at. After generation of WSDL it can read by SOAP library at client side.

Official WSDL specification can be found in here.
http://www.w3.org/TR/wsdl

Sample WSDL document

<definitions name="HelloService"
   targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   <message name="SayHelloRequest">
      <part name="firstName" type="xsd:string"/>
   </message>
 
   <message name="SayHelloResponse">
      <part name="greeting" type="xsd:string"/>
   </message>

   <portType name="Hello_PortType">
      <operation name="sayHello">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>

   <binding name="Hello_Binding" type="tns:Hello_PortType">
      <soap:binding style="rpc"
         transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="sayHello">
         <soap:operation soapAction="sayHello"/>
         <input>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </input>
  
         <output>
            <soap:body
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               namespace="urn:examples:helloservice"
               use="encoded"/>
         </output>
      </operation>
   </binding>

   <service name="Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding="tns:Hello_Binding" name="Hello_Port">
         <soap:address
            location="http://www.examples.com/SayHello/" />
      </port>
   </service>
</definitions>
Code obtained from : http://www.tutorialspoint.com/wsdl/wsdl_example.htm


Understanding the elements of  WSDL

targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
==> target name space means the name space associated with this WSDL document


<documentation>WSDL File for HelloService</documentation>
===> Documentation for this web service (optional)


<message name="SayHelloRequest">
      <part name="firstName" type="xsd:string"/>
   </message>
 
   <message name="SayHelloResponse">
      <part name="greeting" type="xsd:string"/>
   </message>
===> input and output parts of the service (input msg= SayHelloRequest , output msg=SayHelloRespnse)


<portType name="Hello_PortType">
      <operation name="sayHello">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>
===> all the operations are defined here. Currently there is one operation, sayHello and it has one input msg and one output msg described earlier.


<soap:address
            location="http://www.examples.com/SayHello/" />
==> specifies where the service is located at. We can call the web service from this location.

Share:

0 comments: