What is WSDL?

Posted: October 3, 2011 in PHP, Technology

WSDL stands for Web Services Description Language. It is an XML-based language for describing Web services and how to access them. It help to web service consumer to consume. In easy words we can say with the help of WSDL file only user can use web service. WSDL file is key of web service. Without this key web service is useless lock. It specifies the location of the service and the operations (or methods) the services provide.

As communications protocols and message formats are standardized in the web community, it becomes increasingly possible and important to be able to describe the communications in some structured way. WSDL provide this  need by defining an XML grammar for describing network services as collections of communication endpoints capable of exchanging messages . It help to communicate with two technology in common platform. WSDL service definitions provide documentation for distributed systems and serve as a recipe for automating the details involved in applications communication.

WSDL is…

• WSDL is written in XML
• WSDL is an XML document
• WSDL is communication gateway between web service provider and consumer.
• WSDL is used to describe Web services
• WSDL is also used to locate Web services
• WSDL is a W3C recommendation

Elements of WSDL file :-

Following elements are important to any WSDL File

Message – An abstract, typed definition of the data being communicated.

<message name=’getItemCountRequest’>
  <part name=’upc’ type=’xsd:string’/>
</message>
<message name=’getItemCountResponse’>
  <part name=’Result’ type=’xsd:integer’/>
</message>
 

Operation – An abstract description of an action supported by the service. Basically it shows web service operation name and input output message

<operation name=’getItemCount’>
    <input message=’tns:getItemCountRequest’/>
    <output message=’tns:getItemCountResponse’/>
  </operation>
 

Port Type – It describes a web service; operations that can be performed, and messages that are involved in WS.

<portType name=’InventoryPortType’>
  <operation name=’getItemCount’>
    <input message=’tns:getItemCountRequest’/>
    <output message=’tns:getItemCountResponse’/>
  </operation>
</portType>
 

Binding – Communication protocol which is used by web service.

<binding name=’InventoryBinding’ type=’tns:InventoryPortType’>
  <soap:binding style=’rpc’
    transport=’http://schemas.xmlsoap.org/soap/http’/&gt;
  <operation name=’getItemCount’>
    <soap:operation soapAction=’urn:xmethods-delayed-quotes#getItemCount’/>
    <input>
      <soap:body use=’encoded’ namespace=’urn:xmethods-delayed-quotes’
        encodingStyle=’http://schemas.xmlsoap.org/soap/encoding/’/&gt;
    </input>
    <output>
      <soap:body use=’encoded’ namespace=’urn:xmethods-delayed-quotes’
        encodingStyle=’http://schemas.xmlsoap.org/soap/encoding/’/&gt;
    </output>
  </operation>
</binding>
 

• Port – A single endpoint defined as a combination of a binding and a network address.

  <port name=’InventoryPort’ binding=’InventoryBinding’>
    <soap:address location=’http://localhost/soap/server/server.php’/&gt;
  </port>
 

• Service – A collection of related endpoints. it will show which file/path is located for this WSDL file.

<service name=’InventoryService’>
  <port name=’InventoryPort’ binding=’InventoryBinding’>
    <soap:address location=’http://localhost/soap/server/server.php’/&gt;
  </port>
</service>
 
 
 

If you will merge all. File will be look like this

<?xml version=’1.0′ encoding=’UTF-8′ ?>
<definitions name=’Inventory’
  targetNamespace=’urn:test’
  xmlns:tns=’urn:test’
  xmlns:soap=’http://schemas.xmlsoap.org/wsdl/soap/&#8217;
  xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217;
  xmlns:soapenc=’http://schemas.xmlsoap.org/soap/encoding/&#8217;
  xmlns:wsdl=’http://schemas.xmlsoap.org/wsdl/&#8217;
  xmlns=’http://schemas.xmlsoap.org/wsdl/’&gt;
<message name=’getItemCountRequest’>
  <part name=’upc’ type=’xsd:string’/>
</message>
<message name=’getItemCountResponse’>
  <part name=’Result’ type=’xsd:integer’/>
</message>
<portType name=’InventoryPortType’>
  <operation name=’getItemCount’>
    <input message=’tns:getItemCountRequest’/>
    <output message=’tns:getItemCountResponse’/>
  </operation>
</portType>
<binding name=’InventoryBinding’ type=’tns:InventoryPortType’>
  <soap:binding style=’rpc’
    transport=’http://schemas.xmlsoap.org/soap/http’/&gt;
  <operation name=’getItemCount’>
    <soap:operation soapAction=’urn:xmethods-delayed-quotes#getItemCount’/>
    <input>
      <soap:body use=’encoded’ namespace=’urn:xmethods-delayed-quotes’
        encodingStyle=’http://schemas.xmlsoap.org/soap/encoding/’/&gt;
    </input>
    <output>
      <soap:body use=’encoded’ namespace=’urn:xmethods-delayed-quotes’
        encodingStyle=’http://schemas.xmlsoap.org/soap/encoding/’/&gt;
    </output>
  </operation>
</binding>
<service name=’InventoryService’>
  <port name=’InventoryPort’ binding=’InventoryBinding’>
    <soap:address location=’http://localhost/soap/server/server.php’/&gt;
  </port>
</service>
</definitions>
Advertisements
Comments
  1. Pankaj Singh says:

    This is one of the best answer so far, I have read online. No crap, just useful information. Very well presented. I had found another good collection of php interview question and answer over internet. Please check this link…

    http://www.mindstick.com/Interview/244/What%20is%20WSDL

  2. Aditya says:

    good article! Thanks for the information… 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s