Designing a WSDL Client, Discovering Web Services (cont.)

Processing the WSDL File
The WSDL file contains service information in the <service> element. Listing 8 shows a sample WSDL file with one <service> element containing the following children:
  • The <description> element contains the description of the service in simple English.
  • The <port> element serves as one end of the communication channel. Its remote end sits on the other side of the Internet listening to your requests. It contains a "binding" attribute, whose value (TemperatureBinding) refers to the "name" attribute of a <binding> element. The <port> element also contains a <SOAP:address> element (readers familiar with XML namespaces will understand that soap:address means the <address> element belongs to the SOAP namespace and is not part of WSDL schema). This <SOAP:address> element specifies the location of a SOAP server in the form of a URL.

Listing 8 also contains the following elements: a <binding> element and a <portType> element. The <binding> specifies the details of the SOAP binding. The <portType> element describes details of the WSDL interface. The <portType> element contains one operation named "getTemp." Because these two elements are separate, you can design WSDL interfaces independent of their SOAP deployments.

 
Figure 4. Here the user has downloaded a WSDL file containing a setMessage method. This required one parameter type string.

The <port>, <binding>, and <portType> elements are a set, but there may often be more than one. Listing 9 shows another WSDL file that contains a set of these elements.

The client's job is to jump from a <port> element to the matching (they have the same value in their name attributes) <binding> element. The <binding> element furnishes the information needed for the next step.

The WSDLClient in Listing 2 takes either of the following types of WSDL file URLs:

  • http://www.mywebservice.com/mywsdl.wsdl: This is simply a WSDL URL. In this case, read the <service> element and its <port> child, and jump to the matching <binding>. If there is no <service> element, jump to the first instance of a <binding> element.
  • http://www.mywebservice.com/mywsdl.wsdl#mybindingfragmentname: This URL contains a fragment identifier, which is the "name" attribute of the <binding> element. Because you don't need to read the <service> element to get the <binding> element name, you can jump directly to the desired <binding>.

Whatever path you take, you have to reach a <binding> element. The <binding> element has an attribute type specifying the matching <portType> element name. Listing 8 contains only one <portType> element, whose name attribute has the value "TemperaturePortType." This matches the type attribute of the <binding> element.

PortType is the WSDL interface and each operation is a method in that interface. The <portType> element in Listing 8 contains one <operation> element named "getTemp".

Get the <Message> Element
Each of the WSDL methods has input parameters and return values. So the <operation> contains <input> and <output> tags. <input> tags represent input parameters and <output> tags represent return values. Listing 8 contains one each of these elements. Notice that both types of element tag have "message" attributes.

The value of the "message" attribute of the <input> element is "getTempRequest." Look for a <message> element with the same "name" attribute value somewhere in the WSDL file. In Listing 8, the message element with the name attribute value "getTempRequest" lies close to the beginning of the file. But it can be present anywhere in the WSDL file as an immediate child of the <definitions> root element. The <message> element is meant to describe the data type of <input> element.


Introduction WSDL Parsing Strategy

In this Article
Introduction WSDL Parsing Strategy
Processing the WSDL File Authoring the Service Invocation Request
 





FEATURE SOFTWARE:
dtSearch Web
Add power searching to your web site.
Buy Now!

Encrypt It
Encrypt and Decrypt Data, Passwords and Files within your application.
Buy Now!

Standards Organizations and Web Service Coalitions

Key Platforms

Pure-Play Web Services Vendors

Web Service Technologies or Components

From Sun.com

For Further Reading

Discussion Groups
Java Web Services
.NET Web Services

Back to the Special Report

Java Zone

2001 Special Report: Judging Java

TALK BACK
What's your reaction to this article: "Wow! Free reusable WSDL code!" or "Who cares?" Are you actively building Web services in Java now? Do you think WSDL is a reasonable way to describe Web services? Should Sun support Web services as an integral component of J2EE, or is it too soon to tell? Let us know in the Java Web Services discussion group.


Sponsored Links

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers

Copyright Information/Privacy Statement