SCDJWS Study Guide: WSDL
WSDL Document Structure
A WSDL document is an XML document that adheres to the WSDL XML schema. The WSDL schema is available at http://schemas.xmlsoap.org/wsdl/. Theoretically, WSDL can be used to describe any kind of Web service. In this document, only Web services that are SOAP based and compliant with the WS-I Basic Profile 1.0. are described.
The WSDL document is divided into six major elements which come from the “http://schemas.xmlsoap.org/wsdl/” namespace.
The <definitions> element MUST be the root element of all WSDL documents. It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here.
The <types> element describes all the data types used between the client and server. WSDL is not tied exclusively to a specific typing system, but it uses the W3C XML Schema specification as its default choice. If the service uses only XML Schema built-in simple types, such as strings and integers, the types element is not required.
The <message> element describes a one-way message, whether it is a single message request or a single message response. It defines the name of the message and contains zero or more message <part> elements, which can refer to message parameters or message return values.
The <portType> element combines multiple message elements to form a complete one-way or round-trip operation. For example, a portType can combine one request and one response message into a single request/response operation, most commonly used in SOAP services. Note that a portType can (and frequently does) define multiple operations.
The <binding> element describes the concrete specifics of how the service will be implemented on the wire. WSDL includes built-in extensions for defining SOAP services, and SOAP-specific information therefore goes here.
The <service> element defines the address for invoking the specified service. Most commonly, this includes a URL for invoking the SOAP service.
In addition to the six major elements, the WSDL specification also defines the following utility elements:
The <documentation> element is used to provide human-readable documentation and can be included inside any other WSDL element.
The <import> element is used to import other WSDL documents or XML Schemas. This enables more modular WSDL documents. For example, two WSDL documents can import the same basic elements and yet include their own service elements to make the same service available at two physical addresses. Note, however, that not all WSDL tools support the import functionality as of yet.
NOTE: The WSDL schema requires that all sections appear in a specific order: import, types, message, portType, binding, and service. Each abstract section may be in a separate file by itself and imported into the main document.