Sun's Java Web Services Developer Pack (JWSDP) lets you write Web services applications entirely in the Java programming language, but the number and complexity of tools may prove intimidating to JWSDP novice programmers.
JWSDP supports industry standards, ensuring interoperability with technologies and specifications created by standards groups, such as the World Wide Web Consortium (W3C) and the Organization for the Advancement of Structured Information Standards (OASIS). JWSDP also provides several auxiliary tools, such as a WSDL stub compiler that produces a WSDL file for a Web service and a stand-alone Web service UDDI 2.0 registry. JWSDP comes bundled with Apache Tomcat and some Ant tasks, allowing you to register and manage Web services inside Tomcat.
JWSDP's programming interfaces are typically classified by two general categories: those that deal with XML documents and those that deal with remote procedures.
The document-oriented APIs are:
The remote procedure-oriented APIs are:
- · Java API for XML-based RPC (JAX-RPC)
- · Java API for XML Registries (JAXR)
- · Java API for XML Messaging (JAXM)
Let's break down each API set and look at some of the things we can do with each one.
JAXP exposes pluggable APIs for parsing and transforming XML documents without regard for a particular XML processor.
JAXB exposes APIs that enable development of XML-enabled Java applications. JAXB provides tools, APIs, and frameworks for mapping XML documents and Java objects. A compiler is provided for converting XML schemas into Java classes. The binding framework enables error and validity checking of incoming and outgoing XML documents.
JAX-RPC exposes APIs for developing SOAP-based Web service endpoints and clients. JAX-RPC is a required package of the J2EE 1.4 platform.
JAXR exposes APIs for accessing, querying from, and publishing to XML Registries.
The JAXM package exposes APIs for sending and receiving document-oriented XML messages. JAXM supports SOAP 1.1 with Attachments messaging. JAXM works with the concept of messaging profiles, such as ebXML's Transportation, Routing, and Packaging Message Handling Service. This concept enables future support for standards-based messaging protocols.
SAAJ expands on JAXM to enable developers to produce and consume SOAP with attachments messages.
Testing JWSDP's mettle
Let's put JWSDP to the test and see what we have to do to publish a simple Web service. The sample code in Listing A demonstrates how you might publish a simple stock quote service to a registry using JWSDP. Each of the following code listings further illustrates the component capabilities of JWSDP:
- · The executePublish method shown in Listing B handles the bulk of the publishing process. It calls out to several auxiliary methods to carry out tasks such as authentication, creating a service collection, binding services to endpoints, etc.
- · The createOrg method shown in Listing C creates the structure to represent the organization to which the services belong.
- · The addClassifications method shown in Listing D creates the structures needed to classify the services as part of a predefined taxonomy.
- · The connectToRegistry method shown in Listing E creates a connection to a given registry.
- · The disconnect method shown in Listing F closes the connection to the registry.
- · The saveServices method shown in Listing G does the actual publishing of the services to the registry.
- · The bindServices method shown in Listing H binds the services to their endpoints.
- · The authenticate method shown in Listing I authenticates to the registry with a given name and password.
- · The createContact method shown in Listing J creates structures to contain information about contacts for an organization.
Flexibility equals complexity
JWSDP provides a comprehensive palette of tools and APIs for creating and deploying Web services and Web services clients. It is certainly flexible and powerful; however, it is not for the faint of heart. The sheer size of the animal is enough to scare most novices away. But for those who are willing to spend some time with the beast, the possibilities are wide open.