> developer > dnu > courses > Web Services page 8
Web Services
April 2003
DeveloperNet University Course
Reader Rating    from ratings rate this article
View an eBook Version of this course - LARGE FILE! Send this page to a friend

WSDL

Web Services Description Language is a language used to describe a Web Service. In database language, it is meta data, or data about the service. A WSDL document describes what operations the Web Service performs. It also shows the methods that the Web Service exposes and how to talk to the Web Service. A consumer or producer application will find a Web Service by looking for its WSDL document. WSDL is not yet a W3 standard but a working draft.

Two Analogies

Let me try to illustrate the purpose of WSDL with two analogies. First, WSDL is to Web Services what .h files are to C++. In C++, when someone wants to develop to or use your classes, you can give them your .h file and they know how to work with your class. They don't have the implementation of the class, but they know how to interface with it because of the class declaration. Second, WSDL is to Web Services what .class files are to Java. Someone can know how to interface with your class by looking at the .class file. They will again see class and method declarations, but no implementation. In a similar matter, a WSDL document provides necessary information for a subscriber or another producer application to be able to use your Web Service.

WSDL Documents

A WSDL document is an XML file. Just like SOAP, element names have been defined in a namespace that represent the information you need to include in your WSDL document. A WSDL document is encapsulated in a SOAP message when communicating between Web Service applications. When a Web Service is created, many Web Service development tools will create the WSDL document for you. The WSDL document allows consumer applications to find and consume the services provided by the Web Service.

The following table shows a few of the elements of a WSDL document and their attributes.

Elements Attributes
<portType name="" >
Defines the Web Service as well as messages and operations.
<message name= "">
Defines the data elements of the operations.
<types >
Defines the data types used by the Web Service.
<bindings >v
Defines the message format and protocol details.
<operation name= >
Defines the operation that is performed for a method.
<part name= >
Defines a parameter to the method.
<input message= "">
Defines the operation as in input operation.
<output message= "">
Defines the operation as an output operation.

PortType

The <portType> element is the most important of a WSDL document. It defines a web service, the operations that can be performed, and the messages that are involved. We can compare it to a function library or a class in a traditional programming language.

Message, Part, and Bindings

The <message> element defines the data elements of an operation, similar to a function call. The <message> element can have <part> child elements that define the parameters to the function. The <binding> element defines the message format and protocol details for a web service. The binding element has two attributes, the name attribute and the type attribute. The name attribute, which could be any name, defines the name of the binding, and the type attribute points to the port for the binding.

Types

The <types> element defines the data types, such as string and so forth, which the application will recognize. This can also be done using XML Schemas.

Operation, Input, and Output

The operation element defines the operation that is exposed as a Web Service. This is similar to a function prototype. It provides the information about which methods are available in the service. An operation element is similar to a method in a traditional programming language. The <input> and <output> child elements define the direction of the transaction.

Here is a simple example of a WSDL document.


<portType name="Inventory">
<operation name="getItem">
<input message="getItemRequest"/>
<output message="getItemResponse"/>
</operation>
</portType>

<message name="getItemRequest">
<part name="item" type="xs:string"/>
</message>

<message name="getItemResponse">
<part name="value" type="xs:string"/>
</message>

In this sample the <portType> element defines what we can call a library called Inventory. The operation getItem is a method that receives as a parameter getItemRequest and returns getItemResponse.

UDDI

Universal Description Discovery and Integration or UDDI is the last component of Web Services that we will talk about. A commonly used example to illustrate the definition of UDDI is that UDDI is a phone book for Web Services. Web Services are registered in the phone book so that they may be located by consumer applications or other producer applications that want to use the services of a particular application that has already been built. UDDI allows this to happen.

UDDI is a Directory. It allows requests to be made and services each request. The UDDI Directory is publicly available and has an API to allow programmers to access the Directory. The UDDI API is divided into two parts called the Publisher API and the Inquiry API.

UDDI and WSDL are tightly integrated because businesses register their Web Services by sending a WSDL document to the UDDI registry. Queries can also be made by requesting from the UDDI Directory the information contained in a WSDL document. Consumer and producer applications can query the UDDI Directory to find Web Services they need to fulfill their operations.

Figure 4: Web Services sending a WSDL document to the UDDI registry.

Previous Contents Next
download sample file