WSDL
(Web Services Description Language) Introduction
WSDL
is an XML-based language for describing Web services and how to
access them.
-
WSDL stands for Web Services Description Language
-
WSDL is written in XML
-
WSDL is an XML document
-
WSDL is used to describe Web services
-
WSDL is also used to locate Web services
-
WSDL is a W3C recommendation
The
WSDL Document Structure
A
WSDL document describes a web service using these major elements.
<types>
A container for data type definitions used by the web service
<message>
A typed definition of the data being communicated
<portType>
A set of operations supported by one or more endpoints
<binding>
A protocol and data format specification for a particular port type
Structure
as follows:
<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>
WSDL
- The <portType>
Element
The
<portType> element defines a web service, the operations that
can be performed, and the messages that are involved.
<portType>
defines the connection point to a web service.
Operation
Types
:
The
request-response type is the most common operation type, but WSDL
defines four types:
One-way
:
The
service receives a message. The operation therefore has a single
input element.
The
grammar for a one-way operation is:
<wsdl:definitions
....
>
<wsdl:portType
....
>
*
<wsdl:operation
name="nmtoken">
<wsdl:input
name="nmtoken"?
message="qname"/>
</wsdl:operation>
</wsdl:portType
>
</wsdl:definitions>
Request-response
:
The
service receives a message and sends a response.
The
operation therefore has one
input element,
followed by one
output element.
To
encapsulate errors, an optional fault element can also be specified.
The
grammar for a request-response operation is:
<wsdl:definitions
....
>
<wsdl:portType
.... >
*
<wsdl:operation
name="nmtoken"
parameterOrder="nmtokens">
<wsdl:input
name="nmtoken"?
message="qname"/>
<wsdl:output
name="nmtoken"?
message="qname"/>
<wsdl:fault
name="nmtoken"
message="qname"/>*
</wsdl:operation>
</wsdl:portType
>
</wsdl:definitions>
Solicit-response
:
The
service sends a message and receives a response.
The
operation therefore has one
output element,
followed by one input element.
To
encapsulate errors, an optional fault element can also be specified.
The
grammar for a solicit-response operation is:
<wsdl:definitions
....
>
<wsdl:portType
.... >
*
<wsdl:operation
name="nmtoken"
parameterOrder="nmtokens">
<wsdl:output
name="nmtoken"?
message="qname"/>
<wsdl:input
name="nmtoken"?
message="qname"/>
<wsdl:fault
name="nmtoken"
message="qname"/>*
</wsdl:operation>
</wsdl:portType
>
</wsdl:definitions>
Notification
:
The
service sends a message. The operation therefore has a single output
element.
Following
is the grammer for a notification operation:
<wsdl:definitions
....
>
<wsdl:portType
.... >
*
<wsdl:operation
name="nmtoken">
<wsdl:output
name="nmtoken"?
message="qname"/>
</wsdl:operation>
</wsdl:portType
>
</wsdl:definitions>
WSDL
Binding Element
The
<binding> element provides specific details on how a
portType operation will actually be transmitted over the wire.
*
The bindings can be made available via multiple transports, including
HTTP GET, HTTP POST, or SOAP.
*
The bindings provide concrete information on what protocol is being
used to transfer portType operations.
*
The bindings provide information where the service is located.
For
SOAP protocol, the binding is <soap:binding>,
and the transport is SOAP messages on top of HTTP protocol.
*
You can specify multiple bindings for a single portType.
The
binding element has two attributes
-
name attribute : defines the name of the binding
-
type attribute : points to the port for the binding
<binding
name="Hello_Binding" type="tns:Hello_PortType">
SOAP
Binding
This
enables you to specify SOAPspecific details, including SOAP headers,
SOAP encoding styles, and the SOAPAction HTTP header.
The
SOAP extension elements include:
soap:binding
This
element indicates that the binding will be made available via SOAP.
The
style attribute indicates the overall style of the SOAP
message format.
A
style value of rpc specifies an RPC format.
The
transport attribute indicates the transport of the SOAP
messages.
soap:operation
This
element indicates the binding of a specific operation to a specific
SOAP implementation.
soap:body
This
element enables you to specify the details of the input and output
messages.
<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>
WSDL
Ports Element
A
<port> element defines an individual endpoint by
specifying a single address for a binding.
Here
is the grammer to specify a port:
<wsdl:definitions
.... >
<wsdl:service
.... >
*
<wsdl:port
name="nmtoken"
binding="qname">
*
<--
extensibility element (1) -->
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
*
The port element has two attributes :
-
name attribute : provides a unique name among all ports
defined within in the enclosing WSDL document.
-
binding attribute : refers to the binding using the linking
rules defined by WSDL.
*
A port MUST NOT specify more than one address.
*
A port MUST NOT specify any binding information other than address
information.
<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>
Reference
: http://www.w3schools.com