WSDL Document
A WSDL document is just a simple XML document. It contains a series of definitions that describe a web service.
WSDL Document Structure
A WSDL document uses these main elements to describe a web service:
Element | Definition |
---|---|
<portType> | Web service operations |
<message> | Messages used by the web service |
<types> | Data types used by the web service |
<binding> | Communication protocol used by the web service |
The main structure of a WSDL document looks like this:
WSDL Document Example
<definitions>
<types>
data type definitions........
</types>
<message>
definition of the data being communicated....
</message>
<portType>
set of operations......
</portType>
<binding>
protocol and data format specification....
</binding>
</definitions>
A WSDL document can contain other elements, such as extension elements, and a service element, which can group definitions of several web services into a single WSDL document.
WSDL Port
The <portType> element is the most important WSDL element.
It describes a web service, the operations that can be performed, and the related messages.
You can compare the <portType> element to a function library (or a module, or a class) in traditional programming languages.
WSDL Messages
The <message> element defines the data elements for an operation.
Each message consists of one or more parts. These parts can be compared to the parameters of a function call in traditional programming languages.
WSDL Types
The <types> element defines the data types used by the web service.
For maximum platform neutrality, WSDL uses the XML Schema syntax to define data types.
WSDL Bindings
The <binding> element defines the message format and protocol details for each port.
WSDL Example
Here is a simplified snippet of a WSDL document:
<message name="getTermRequest">
<part name="term" type="xs:string"/>
</message>
<message name="getTermResponse">
<part name="value" type="xs:string"/>
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
In this example, the <portType> element defines "glossaryTerms" as the name of a port and "getTerm" as the name of an operation.
The "getTerm" operation has an input message named "getTermRequest" and an output message named "getTermResponse".
The <message> element defines the parts of each message and their associated data types.
By analogy with traditional programming, glossaryTerms is a function library, and "getTerm" is a function with an input parameter "getTermRequest" and a return parameter "getTermResponse".