0: Quick reference

I wrote this piece of crap for myself, to understand WSDL file structure. Hopefully, others will also get benefit out of this. WSDL stands for Web Services Description Language. It is a document written in XML. A WSDL file defines contract - specifies the location of the service, and the operations (or methods or functions) a web service exposes. WSDL 2.0 was first developed as WSDL 1.2 but was renamed to signify its differences from earlier version. Few of the significant changes are:
• • • • •

Adding more semantics to the description language. Removal of message constructs. These are specified using the XML schema type system in the types element. No support for operator overloading. PortTypes renamed to interfaces. Support for interface inheritance is achieved by using the extends attribute in the interface element. Ports renamed to endpoints.


Conceptual Model
The description consists of two parts. In the abstract part, WSDL describes a web service in:
• • • •

Messages it sends and receives using a type system (typically W3C XML Schema). Message exchange patterns that define the sequence and cardinality of messages. Operations that associates message exchange patterns with one or more messages. Interfaces group these operations in a transport and wire independent manner.

In the concrete part of the description:
• • •

Bindings specify the transport and wire format for interfaces. A service endpoint associates network address with a binding. A service groups the endpoints that implement a common interface.

Following is a basic WSDL structure 1. 2. 3. 4. 5. 6. <definitions targetNamespace="xs:anyURI"> <documentation /> ? [<import /> | <include /> ] * <types /> ? [<interface /> | <binding /> | <service /> ] * </definitions>

The definitions element serves as a container.

1. <definitions name="StockQuote" 2. targetNamespace="" 3. xmlns:tns="" 4. xmlns:xsd1="" 5. xmlns:soap="" 6. xmlns="">

The include element helps to modularize the web service descriptions. Included documents must have the same target namespace.

The concept behind the import element is very similar to that of include element, except that the imported WSDL can be in different target namespaces. 1. <import namespace="" 2. location=""/>

The types element defines the data types used by the exchanged messages. WSDL uses W3C XML Schema as its preferred schema language. The following example refers to an imported XSD. 1. <types> 2. <schema 3. targetNamespace=""> 4. <element name="GetLastTradePriceInput" 5. type="xsd1:TradePriceRequest"/> 6. <element name="GetLastTradePriceOutput" 7. type="xsd1:TradePrice"/> 8. </schema> 9. </types>

An interface element encloses a named set of abstract operations and the abstract messages. It can extend one or more other interfaces. Interfaces are referred to by QName in other components. 1. <interface name="StockQuoteInterface"> 2. <operation name="GetLastTradePrice" pattern=""> 3. <input message="tns:GetLastTradePriceInput"/> 4. <output message="tns:GetLastTradePriceOutput"/> 5. </operation> 6. </interface>


The binding element defines the underlying transport and wire format for messages. Each binding references to an interface. 1. <binding name="StockQuoteSoapBinding" 2. interface="defs:StockQuoteInterface"> 3. <soap:binding protocol=""/> 4. <operation name="GetLastTradePrice"> 5. <soap:operation 6. soapAction=""/> 7. <input> 8. <soap:body/> 9. </input> 10. <output> 11. <soap:body/> 12. </output> 13. </operation> 14. </binding>

A service element describes a set of endpoints which refer to a single network address for a binding. All other protocol specific information is contained in the binding. 1. <service name="StockQuoteService"> 2. <documentation>My stock quote service</documentation> 3. <endpoint name="StockQuoteEndPoint" 4. binding="tns:StockQuoteSoapBinding"> 5. <soap:address location=""/> 6. </endpoint> 7. </service>

Example WSDL Code



In fact WSDL format is over-engineered but you have to live with it. So better to know about it.


Sign up to vote on this title
UsefulNot useful