background image

SOAPMessage Object

<< Messages with Attachments | SAAJ Connections >>
<< Messages with Attachments | SAAJ Connections >>

SOAPMessage Object

to contain a binary file, your message must have an attachment part for it. Note that an
attachment part can contain any kind of content, so it can contain data in XML format as well.
Figure 19­2
shows the high-level structure of a SOAP message that has two attachments.
The SAAJ API provides the AttachmentPart class to represent an attachment part of a SOAP
message. A SOAPMessage object automatically has a SOAPPart object and its required
subelements, but because AttachmentPart objects are optional, you must create and add them
yourself. The tutorial section walks you through creating and populating messages with and
without attachment parts.
If a SOAPMessage object has one or more attachments, each AttachmentPart object must have a
MIME header to indicate the type of data it contains. It may also have additional MIME headers
SOAPMessage (an XML document)
SOAPPart
SOAPEnvelope
SOAPHeader (optional)
Headers (if any)
SOAPBody
XML Content
or SOAPFault
AttachmentPart
Content (XML or non-XML)
MIME Headers
AttachmentPart
Content (XML or non-XML)
MIME Headers
FIGURE 19­2
SOAPMessage
Object with Two AttachmentPart Objects
Overview of SAAJ
The Java EE 5 Tutorial · September 2007
588