What is a WSDL?
WSDL, webservice description language, is the contract definition of any webservice. This XML document is used to tell the world what is going to be the definition/structure of the webservice, what that webservice has to offer. Here is an example webservice document explained using inline comments. We are not taking any complex example here. But it is very close to real life wsdl. There are many tools available that can be used to write wsdl.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.myhomepageindia.com/ws/ExampleServices"
xmlns="http://www.myhomepageindia.com/ws/ExampleServices"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Document the wsdl -->
<wsdl:documentation>
This is an example service.
</wsdl:documentation>
<!-- types are the input and output parameters you are going
to use in the operations. Ensure usage of generic types that can
be recongnised in all technologies implementing web service -->
<wsdl:types>
<xs:schema targetNamespace="http://www.myhomepageindia.com/sample.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sampleRequest">
<xs:complexType>
<xs:all>
<xs:element name="param1" type="string"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="sampleResponse">
<xs:complexType>
<xs:all>
<xs:element name="result1" type="float"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<!-- These are the data elements of operations of webservice.
We use the types defined above to define define the messages.
These map to the input/output parameters of the underlying webservice implementation.-->
<wsdl:message name="sampleRequest">
<wsdl:part name="SampleRequest" element="sampleRequest" />
</wsdl:message>
<wsdl:message name="sampleResponse">
<wsdl:part name="SampleResponse" element="sampleResponse" />
</wsdl:message>
<!-- Operations exposed by web service. These map to the methods/operations
of webservice. Type of operations are - one way (containing only input),
request-response (both input and output), solicit response (does wait
for response), notification (does not wait for response)-->
<wsdl:portType name="SampleWS">
<wsdl:operation name="sampleOperation">
<wsdl:documentation>
Sample operation
</wsdl:documentation>
<wsdl:input message="sampleRequest" />
<wsdl:output message="sampleResponse" />
</wsdl:operation>
</wsdl:portType>
<!-- Defines message format and protocol details of webservice.
Here the transport is http.
Also it defines the url to be used to access.-->
<wsdl:binding name="SampleWS" type="SampleWS">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sampleOperation">
<soap:operation
soapAction="http://${hostname}:${port}/ExampleServices/ws/sampleOperation" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
