Sie sind auf Seite 1von 6

WSDL 2.

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.

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

Definitions
The definitions element serves as a container.
2

1. <definitions name="StockQuote" 2. targetNamespace="http://example.com/stockquote/definitions" 3. xmlns:tns="http://example.com/stockquote/definitions" 4. xmlns:xsd1="http://example.com/stockquote/schemas" 5. xmlns:soap="http://www.w3.org/2003/11/wsdl/soap12" 6. xmlns="http://www.w3.org/2003/11/wsdl">

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

Import
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="http://example.com/stockquote/schemas" 2. location="http://example.com/stockquote/stockquoteV20.xsd"/>

Types
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="http://example.com/stockquote/definitions"> 4. <element name="GetLastTradePriceInput" 5. type="xsd1:TradePriceRequest"/> 6. <element name="GetLastTradePriceOutput" 7. type="xsd1:TradePrice"/> 8. </schema> 9. </types>

Interface
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="http://www.w3.org/2003/11/wsdl/in-out"> 3. <input message="tns:GetLastTradePriceInput"/> 4. <output message="tns:GetLastTradePriceOutput"/> 5. </operation> 6. </interface>

Binding
3

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="http://www.w3.org/2003/11/wsdl/http"/> 4. <operation name="GetLastTradePrice"> 5. <soap:operation 6. soapAction="http://example.com/GetLastTradePrice"/> 7. <input> 8. <soap:body/> 9. </input> 10. <output> 11. <soap:body/> 12. </output> 13. </operation> 14. </binding>

Service
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="http://example.com/stockquote"/> 6. </endpoint> 7. </service>

Example WSDL Code

Conclusion
5

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

Das könnte Ihnen auch gefallen