WSDL: Difference between revisions

6 bytes removed ,  3 December 2007
m
tidying up
m (tweak)
m (tidying up)
Line 10: Line 10:
WSDL can be quite formidable to understand for those not used to looking at such things. Probably the easiest way to get to grips with it is to break it down into its various components.
WSDL can be quite formidable to understand for those not used to looking at such things. Probably the easiest way to get to grips with it is to break it down into its various components.


After any initial processing instruction (<?xml version="1.0" encoding="UTF-8"?> or similar) there will be the outer '''<definitions>''' element, which will typically also define a number of '''''[[namespace]]s''''' that will be used in the document.
After any initial processing instruction (<?xml version="1.0" encoding="UTF-8"?> or similar) there will be the outer '''<definitions>''' element, which will typically also define a number of '''''[[XML namespaces]]''''' that will be used in the document.


Within that there will (usually, and in WSDL 1.1) be four or five main types of element, grouped together, in the following order:
Within that there will (usually, and in WSDL 1.1) be four or five main kinds of element, grouped together, in the following order:


*'''types''' - only one element (optional) describing the extended data types used by the service
*'''types''' - only one element (optional) describing the extended data types used by the service
Line 25: Line 25:
The definitions element, as well as serving as the XML document root, also defines (some of) the namespaces used in the document.  Typically these will include:
The definitions element, as well as serving as the XML document root, also defines (some of) the namespaces used in the document.  Typically these will include:


* The base WSDL namespace: ="<span style="color:midnightblue;">xmlns="<nowiki>http://schemas.xmlsoap.org/wsdl/</nowiki>"</span>
* The base WSDL namespace: <span style="color:midnightblue;">xmlns="<nowiki>http://schemas.xmlsoap.org/wsdl/</nowiki>"</span>
* The XML Schema namespace, where the base XML types are defined: ="<span style="color:midnightblue;">xmlns:xs="<nowiki>http://www.w3.org/2001/XMLSchema</nowiki>"</span>
* The XML Schema namespace, where the base XML types are defined: <span style="color:midnightblue;">xmlns:xs="<nowiki>http://www.w3.org/2001/XMLSchema</nowiki>"</span>
* The [[SOAP]] namespace: ="<span style="color:midnightblue;">xmlns:soap<nowiki>"http://schemas.xmlsoap.org/wsdl/soap/</nowiki>"</span>
* The [[SOAP]] namespace: <span style="color:midnightblue;">xmlns:soap="<nowiki>http://schemas.xmlsoap.org/wsdl/soap/</nowiki>"</span>
* The service's own namespace, which is usually associated with the namespace prefix "tns" - ('''t'''his '''n'''ame'''s'''pace): ="<span style="color:midnightblue;">xmlns:tns="http://''yourDomain/yourService/serviceName''"</span>
* The service's own namespace, which is usually associated with the namespace prefix "tns" - ('''t'''his '''n'''ame'''s'''pace): <span style="color:midnightblue;">xmlns:tns="http://''yourDomain/yourService/serviceName''</span>
* The "target" namespace, which is often identical to the "tns" one: ="<span style="color:midnightblue;">targetNamespace="http://''yourDomain/yourService/serviceName''"</span>
* The "target" namespace, which is often identical to the "tns" one: <span style="color:midnightblue;">targetNamespace="http://''yourDomain/yourService/serviceName''"</span>


There may be ''many'' more than these (look at any Microsoft .Net service WSDL), but most services will define at least these ones as a minimum, although not always in exactly that form. In particular, the choice of namespace prefixes is arbitrary, so the base namespace might be specified as "xmlns:wsdl", rather than just "xmlns"; "xmlns:xs" is often seen as "xmlns:xsd"; "xmlns:soap" might be "xmlns:soap12" (in reference to SOAP 1.2) or many other variations - remember that it is the actual namespace URI that is being referenced that is important, not the prefix used to represent it in the document, which can be anything.
There may be ''many'' more than these (look at any Microsoft .Net service WSDL), but most services will define at least these ones as a minimum, although not always in exactly that form. In particular, the choice of namespace prefixes is arbitrary, so the base namespace might be specified as "xmlns:wsdl", rather than just "xmlns"; "xmlns:xs" is often seen as "xmlns:xsd"; "xmlns:soap" might be "xmlns:soap12" (in reference to SOAP 1.2) or many other variations - remember that it is the actual namespace URI that is being referenced that is important, not the prefix used to represent it in the document, which can be anything.