1.4 J2EE Web Service APIs


1.4 J2EE Web Service APIs

Java web services are one of the major new features in the J2EE 1.4 platform, which has integrated versions of some of the APIs that Sun Microsystems released as part of the Java Web Services Developer's Pack in 2002. Figure 1-2 shows the various web service APIs (represented by the shaded areas) and how they fit together.

Figure 1-2. The J2EE 1.4 and JWSDP web service APIs

Working up from the bottom of the diagram, by definition, all web services depend on XML, since the messages exchanged between the service provider and the service consumer are encoded in XML. At the present time, these messages are carried using the SOAP protocol, which is itself based on XML. It is generally accepted, however, that SOAP is only the current state of the art and need not be the only web service protocol. Layered above SOAP and XML are the various web service APIs, which are summarized in the following sections:


As described earlier, WSDL is an XML vocabulary used to describe the interface provided by a web service. Both J2EE 1.4 and JWSDP support the use of WSDL 1.1 to specify service interfaces, but do not provide an API for application code to directly manipulate WSDL. At the time of this writing, a standard API (called JWSDL) that provides this functionality is under development by the JSR 110 expert group . See http://jcp.org/jsr/detail/110.jsp for details. WSDL is discussed in Chapter 5.


SAAJ (SOAP with Attachments API for Java) provides a direct programming interface to the SOAP protocol. If you are used to low-level protocol handling and don't mind building your own SOAP messages, then you will likely find SAAJ quite simple to use, but for most application developers it is probably not the right place to start. You'll find detailed coverage of the API in Chapter 3.


SAAJ provides a basic SOAP messaging service, but it is lacking some features required by more advanced applications. The Java API for XML Messaging (JAXM), which is layered on top of SOAP, provides some additional functionality that many developers will find useful, including asynchronous messaging, support for the ebXML and WS-Routing profiles, and a limited facility to retransmit messages that are not successfully delivered when first sent. A reference implementation of JAXM, which is the subject of Chapter 4, is available in the JWSDP, but was not formally adopted as part of the J2EE 1.4 platform. There is, however, the possibility that some vendors will nevertheless provide JAXM support in their products.


For most developers, the Java API for XML-based RPC (JAX-RPC) is the most important web service API in the J2EE 1.4 platform (and in the JWSDP). JAX-RPC provides a relatively simple way to access web services using Java programming language constructs, thereby entirely shielding the underlying SOAP- and XML-based infrastructure from those who do not wish to see it. The JAX-RPC API is relatively small, but still manages to provide such a large number of features that it requires two chapters in this book (Chapter 2 and Chapter 6) to provide complete coverage.


The Java API for XML-based Registries (JAXR) provides an interface to both UDDI and ebXML registries. Although this API can be used by any application, it is most likely to be of use to developers who wish to create tools that allow easy access to registries or provide custom searches. JAXR allows both the publication of information to registries and information retrieval. Full coverage of this API can be found in Chapter 7.

The most obvious omission from the suite of web service APIs included with the J2EE 1.4 platform is anything relating to security. Although the use of HTTPS is supported, this is not a complete solution for applications that have high security requirements, and there are several working groups currently engaged in the specification of security mechanisms for XML-based messaging. These efforts are being tracked by JCP expert groups and, no doubt, over the next year additional packages will be released that can be added to the J2EE 1.4 platform to incorporate these features.