The JavaTM Web Services Tutorial

Java API for XML Messaging

Maydene Fisher

The Java API for XML Messaging (JAXM) makes it possible for developers to do XML messaging using the Java platform. By simply making method calls using the JAXM API, you can create and send XML messages over the Internet. This chapter will help you learn how to use the JAXM API.

The JAXM API conforms to the Simple Object Access Protocol (SOAP) 1.1 specification and the SOAP with Attachments specification. The complete JAXM API is presented in two packages:

Originally, both packages were defined in the JAXM 1.0 specification. The javax.xml.soap package was separated out and expanded into the SAAJ 1.1 specification so that now it has no dependencies on the javax.xml.messaging package and thus can be used independently. The SAAJ API also makes it easier to create XML fragments, which is especially helpful for developing JAX-RPC implementations.

The javax.xml.messaging package, defined in the JAXM 1.1 specification, maintains its dependency on the java.xml.soap package because the soap package contains the API used for creating and manipulating SOAP messages. In other words, a client sending request-response messages can use just the javax.xml.soap API. A Web service or client that uses one-way messaging will need to use API from both the javax.xml.soap and javax.xml.messaging packages.

Note: In this document, "JAXM 1.1_01 API" refers to the API in the javax.xml.messaging package; "SAAJ API" refers to the API in the javax.xml.soap package. "JAXM API" is a more generic term, referring to all of the API used for SOAP messaging, that is, the API in both packages.

In addition to stepping you through how to use the JAXM API, this chapter gives instructions for running the sample JAXM applications included with the Java WSDP as a way to help you get started. You may prefer to go through both the overview and tutorial before running the samples to make it easier to understand what the sample applications are doing, or you may prefer to explore the samples first. The overview gives some of the conceptual background behind the JAXM API to help you understand why certain things are done the way they are. The tutorial shows you how to use the basic JAXM API, giving examples and explanations of the more commonly used features. Finally, the code examples in the last part of the tutorial show how to build an application.

In This Chapter
Overview of JAXM
Messaging Providers
Running the Samples
The Sample Programs
Source Code for the Samples
Client without a Messaging Provider
Client with a Messaging Provider
Adding Attachments
SOAP Faults
Code Examples and
Further Information

This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.

All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.