background image

What Is in a Message

<< Overview of SAAJ | Messages with No Attachments >>
<< Overview of SAAJ | Messages with No Attachments >>
M
ESSAGES
119
resent XML elements in a SOAP message. There are also methods such as
SOAPElement.addTextNode
,
Node.detachNode
, and
Node.getValue
, which
you will see how to use in the tutorial section.
What Is in a Message?
The two main types of SOAP messages are those that have attachments and
those that do not.
Messages with No Attachments
The following outline shows the very high-level structure of a SOAP message
with no attachments. Except for the SOAP header, all the parts listed are required
to be in every SOAP message.
I. SOAP message
A. SOAP part
1. SOAP envelope
a. SOAP header (optional)
b. SOAP body
The SAAJ API provides the
SOAPMessage
class to represent a SOAP message,
the
SOAPPart
class to represent the SOAP part, the
SOAPEnvelope
interface to
represent the SOAP envelope, and so on. Figure 5­1 illustrates the structure of a
SOAP message with no attachments.
Note: Many SAAJ API interfaces extend DOM interfaces. In a SAAJ message, the
SOAPPart
class is also a DOM document. See SAAJ and DOM (page 122) for
details.
When you create a new
SOAPMessage
object, it will automatically have the parts
that are required to be in a SOAP message. In other words, a new
SOAPMessage
object has a
SOAPPart
object that contains a
SOAPEnvelope
object. The
SOAPEn-
velope
object in turn automatically contains an empty
SOAPHeader
object fol-
lowed by an empty
SOAPBody
object. If you do not need the
SOAPHeader
object,
which is optional, you can delete it. The rationale for having it automatically
included is that more often than not you will need it, so it is more convenient to
have it provided.