Basics of WSDL in a simple language
WSDL stands for Web Services Description Language
WSDL is an XML document , describes Web services, used to locate web services, specifies operations web services exposes.
WSDL Structure
Major elements of a webservice
| Element | Defines |
|---|---|
| <types> | The data types used by the web service |
| <message> | The messages used by the web service. Like function parameters. |
| <portType> | It describes a web service, the operations that can be performed, and the messages that are involved. Its the most important type. Equivalent to a interface. |
| <binding> | The format and protocols used by the web service |
| <service> | A collection of related ports |
A WSDL can also contain other elements, like extension elements, and a service element that makes it possible to group together the definitions of several web services in one single WSDL
WSDL Example
<message name=”Request”>
<part name=”term” type=”string”/>
</message>
<message name=”Response”>
<part name=”value” type=”string”/>
</message>
<message name=”Fault”>
<part name=”value” type=”string”/>
</message>
<portType name=”port”>
<operation name=”method”>
<input message=”Request”/>
<output message=”Response”/>
<fault message=”Fault”/>
</operation>
</portType>
<binding type=”port” name=”b1″>
<soap:binding style=”document”
transport=”http://schemas.xmlsoap.org/soap/http” />
<operation>
<soap:operation soapAction=”http://example.com/port”/>
<input><soap:body use=”literal”/></input>
<output><soap:body use=”literal”/></output>
</operation>
</binding>
<service name=”Service”>
<port name=”Port” binding=”b1″>
<soap:address location=”http://loaclhost:8080/example”/>
</port>
</service>
In this example the <portType> element defines the name of a port, and the name of an operation. The operation has an input message and an output message and a fault message. The <message> elements define the parts of each message and the associated data types.The request-response type is the most common operation type, but WSDL defines four types:
| Type | Definition |
|---|---|
| One-way | The operation can receive a message but will not return a response |
| Request-response | The operation can receive a request and will return a response |
| Solicit-response | The operation can send a request and will wait for a response |
| Notification | The operation can send a message but will not wait for a response |
The binding element has two attributes – name and type.
The name attribute (you can use any name you want) defines the name of the binding, and the type attribute points to the port for the binding.
The soap:binding element has two attributes – style and transport.
The style attribute can be “rpc” or “document”. In this case we use document. The transport attribute defines the SOAP protocol to use. In this case we use HTTP.
The operation element defines each operation that the port exposes.
For each operation the corresponding SOAP action has to be defined. You must also specify how the input and output are encoded. In this case we use “literal”.
The service element defines the ports supported by the Web service. For each of the supported protocols, there is one port element.
Port, specifies an address for a binding, thus defining a single communication endpoint.
Filed under: Uncategorized | Leave a Comment
Tags: webservice, wsdl
No Responses Yet to “Basics of WSDL in a simple language”