Publish and find UDDI tModels with JAXR and WSDL
Work with WSDL, JAXR, and UDDI
By Frank Sommers, JavaWorld.com, 09/20/02
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Imagine you are a travel agent and frequently book cruise ship vacations. To offer your customers choice, you must maintain
an up-to-date list of exotic destinations. In the past, you could have gathered this information by obtaining cruise ship
company directories, inspecting each company's Website, or telephoning cruise operators to find out what cities their companies
served.
Web services allow you to compile and maintain such lists automatically. That convenience comes with two requirements: First,
cruise ship companies must agree to use a common Web service interface when publishing their destinations. Second, each company
must implement that interface and register its implementation in Web service registries. With those requirements satisfied,
you can consult Web service registries, discover all cruise destination service instances, invoke each service, and produce
your cruise destinations master list.
The pattern of finding all implementations of a Web service interface and possibly invoking those service instances proves
useful in other contexts as well. Portal Websites still rely on manual—or semi-manual—compilation of news articles, automobile
inventories, available hotel rooms, or airline seats. Even when data exchanges electronically, that automation often comes
at the expense of lengthy and pricey system integration. Among the biggest motivations for building Web services is the desire
to automate those tedious information-gathering tasks. This article provides a working example of how UDDI (Universal Description,
Discovery, and Integration) registries, the Java API for XML Registries (JAXR), and the Web Services Description Language
(WSDL) work together to initiate that automation.
Reuse your WSDL
Currently, several industry groups are working to define Web service interface standards. Examples are the Open Travel Alliance
for travel, the Star Consortium for automotive retail, and RosettaNet for supply chain management. Many of those groups employ
a community-oriented process and make their specifications available to anyone for comments.
Real-world interface specifications aim to be comprehensive and are rather complex. Thus, to make this article easy to follow,
I use a simple interface definition for the example cruise ship destination Web service. That interface features only a single
method. When invoked, that method produces a list of destinations a cruise company serves. Here is that interface in Java:
public interface CruiseService {
public String[] cruiseDestinations();
}
Because Web services aim to remain programming language-neutral, we must convert this interface definition to a format not
tied to Java. WSDL defines a document structure suitable for describing Web service interfaces with XML data elements. My
previous Web Services column demonstrated how development tools, such as open source Apache Axis, convert a Java interface to a WSDL document.
As apparent from Web service-related discussion lists, many developers debate the better practice: first define your Web service's
interface with code—for instance, Java code—then convert that code to WSDL definitions, or create the WSDL documents first,
then convert those documents to Java code. Finding the right method might have more to do with personal predilection than
hard and fast rules. I prefer to define a service's interface in Java (or some other language) first, because I find that
a programming language-based definition produces a clearer, simpler picture of a service's capabilities. WSDL-first advocates
have a point too: converting Java interfaces to XML structures is not an exact science and can introduce subtleties leading
to surprising results.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- The Open Travel Alliance aims to define Web services interfaces for the travel industry
http://www.opentravel.org
- The Start Consortium's goal is similar in the context of automotive
http://www.starstandard.org
- RosettaNet is a consortium interested in interoperability standards and XML-based interfaces in the supply-chain industry
http://www.rosettanet.org
- "I Like Your TypeDescribe and Invoke Web Services Based on Service Type," Frank Sommers (JavaWorld, September 2002)
http://www.javaworld.com/javaworld/jw-09-2002/jw-0920-webservices.html
- "Web Services Take Float with JAXR," Frank Sommers (JavaWorld, May 2002) describes how to categorize Web services based on business and geographic categories using JAXR
http://www.javaworld.com/javaworld/jw-05-2002/jw-0517-webservices.html
- "The Adventures of JWSDP," Frank Sommers (JavaWorld, May 2002)
http://www.javaworld.com/javaworld/jw-05-2002/jw-0517-jwsdp.html
- WSDL 1.2
http://www.w3.org/TR/2002/WD-wsdl12-20020709/
- The U.S. Census Bureau maintains information about the North American Industry Classification System (NAICS)
http://www.census.gov/epcd/www/naics.html
- JSR 93, the Java API for XML Registries 1.0
http://www.jcp.org/en/jsr/detail?id=93
- The World Wide Web Consortium's (W3C) work on the XML protocol (formerly known as SOAP)
http://www.w3.org/2000/xp/Group/
- The Apache Axis project
http://xml.apache.org/axis/index.html
- "AxisThe Next Generation of Apache SOAP," Tarak Modi (JavaWorld, January 2002)
http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-axis.html
- The Apache Jakarta Project
http://jakarta.apache.org
- "UDDI4J Lets Java Do the Walking," André Tost (JavaWorld, August 2001)
http://www.javaworld.com/javaworld/jw-08-2001/jw-0824-uddi.html
- The W3C maintains the following page on XML namespaces
http://www.w3.org/TR/1999/REC-xml-names-19990114/
- The XML Schema recommendations
http://www.w3.org/XML/Schema
- JSR 110 aims to define an API to interface with WSDL documents
http://www.jcp.org/jsr/detail/110.jsp
- IBM's WSDL4J is an implementation of the JWSDL specifications
http://www-124.ibm.com/developerworks/projects/wsdl4j/
- Sun's Web services and Java page
http://java.sun.com/webservices/
- Pointers to the main UDDI registries
http://www.uddi.org.
- Stay current with JavaWorld's Web Services column
http://www.javaworld.com/columns/jw-web-services-index.shtml
- Browse the Java and Web Services section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-webserv-index.shtml
- Browse the Java and XML section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-xml-index.shtml
- Frank Sommers also writes JavaWorld's Jiniology column
http://www.javaworld.com/columns/jw-jiniology-index.shtml
- Also written by Frank Sommers"Effort on the Edge, Part 1" (JavaWorld, November 2002)
http://www.javaworld.com/javaworld/jw-11-2002/jw-1108-jcp.html
- Subscribe to JavaWorld's free Enterprise Java email newsletter
http://www.javaworld.com/subscribe
- Speak out in JavaWorld's Enterprise Java Discussion
http://forums.idg.net/webx?50@@.ee6b80a
- You'll find a wealth of IT-related articles from our sister publications at IDG.net