A SOAPMessage object consists of a SOAP part and optionally
one or more attachment parts. The SOAP part for a SOAPMessage
object is a SOAPPart object, which contains information used
for message routing and identification, and which can contain
application-specific content. All data in the SOAP Part of a message must be
in XML format.
A new SOAPMessage object contains the following by default:
SOAPPart object
SOAPEnvelope object
SOAPBody object
SOAPHeader object
SOAPMessage.getSOAPPart().
The SOAPEnvelope object is retrieved from the SOAPPart
object, and the SOAPEnvelope object is used to retrieve the
SOAPBody and SOAPHeader objects.
SOAPPart sp = message.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPBody sb = se.getBody();
SOAPHeader sh = se.getHeader();
In addition to the mandatory SOAPPart object, a SOAPMessage
object may contain zero or more AttachmentPart objects, each
of which contains application-specific data. The SOAPMessage
interface provides methods for creating AttachmentPart
objects and also for adding them to a SOAPMessage object. A
party that has received a SOAPMessage object can examine its
contents by retrieving individual attachment parts.
Unlike the rest of a SOAP message, an attachment is not required to be in
XML format and can therefore be anything from simple text to an image file.
Consequently, any message content that is not in XML format must be in an
AttachmentPart object.
A MessageFactory object may create SOAPMessage
objects with behavior that is specialized to a particular implementation or
application of SAAJ. For instance, a MessageFactory object
may produce SOAPMessage objects that conform to a particular
Profile such as ebXML. In this case a MessageFactory object
might produce SOAPMessage objects that are initialized with
ebXML headers.
In order to ensure backward source compatibility, methods that are added to
this class after version 1.1 of the SAAJ specification are all concrete
instead of abstract and they all have default implementations. Unless
otherwise noted in the JavaDocs for those methods the default
implementations simply throw an UnsupportedOperationException
and the SAAJ implementation code must override them with methods that
provide the specified behavior. Legacy client code does not have this
restriction, however, so long as there is no claim made that it conforms to
some later version of the specification than it was originally written for.
A legacy class that extends the SOAPMessage class can be compiled and/or run
against succeeding versions of the SAAJ API without modification. If such a
class was correctly implemented then it will continue to behave correctly
relative to the version of the specification against which it was written.
MessageFactory, AttachmentPart
| Modifier and Type | Field and Description |
|---|---|
| public static final String | CHARACTER_SET_ENCODING
Specifies the character type encoding for the SOAP Message. |
| public static final String | WRITE_XML_DECLARATION
Specifies whether the SOAP Message will contain an XML declaration when it is sent. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | addAttachmentPart(AttachmentPart
an attachmentPart)attachmentPart object that is to become part
of this SOAPMessage objectAdds the given |
| public abstract int | Returns: the number ofAttachmentPart objects that are
part of this SOAPMessage objectGets a count of the number of attachments in this message. |
| public abstract AttachmentPart | Returns: a newAttachmentPart object that can be populated
and added to this SOAPMessage objectCreates a new empty |
| public AttachmentPart | Returns: a newAttachmentPart object that contains data
generated by the given DataHandler objectthe dataHandler)jakarta.activation.DataHandler object that
will generate the content for this SOAPMessage
objectCreates an |
| public AttachmentPart | Returns: a newAttachmentPart object that contains the
given dataan content, String Object containing the content for the
AttachmentPart object to be createda contentType)String object giving the type of content;
examples are "text/xml", "text/plain", and "image/jpeg"Creates an |
| public abstract AttachmentPart | Returns: the referencedAttachmentPart or null if no such
AttachmentPart exists or no reference can be
found in this SOAPElement.The element)SOAPElement containing the reference to an AttachmentReturns an |
| public abstract Iterator | Returns: an iterator over all the attachments in this messageRetrieves all the |
| public abstract Iterator | Returns: an iterator over all attachments that have a header that matches one of the given headersa headers)MimeHeaders object containing the MIME
headers for which to searchRetrieves all the |
| public abstract String | Returns: aString describing the content of this
message or null if no description has been setRetrieves a description of this |
| public abstract MimeHeaders | Returns: aMimeHeaders object containing the MimeHeader
objectsReturns all the transport-specific MIME headers for this |
| public Object | Returns: the value associated with the named property ornull
if no such property exists.the name of the property to retrieve property)Retrieves value of the specified property. |
| public SOAPBody | Returns: theSOAPBody object contained by this SOAPMessage
objectGets the SOAP Body contained in this |
| public SOAPHeader | Returns: theSOAPHeader object contained
by this SOAPMessage objectGets the SOAP Header contained in this |
| public abstract SOAPPart | Returns: theSOAPPart object for this SOAPMessage
objectGets the SOAP part of this |
| public abstract void | removeAllAttachments()
Removes all |
| public abstract void | removeAttachments(MimeHeaders
a headers)MimeHeaders object containing the MIME
headers for which to searchRemoves all the |
| public abstract void | |
| public abstract boolean | Returns: true if saveChanges needs to be
called; false otherwise.Indicates whether this |
| public abstract void | setContentDescription(String
a description)String describing the content of this
messageSets the description of this |
| public void | setProperty(String
the property with which the specified value is to be
associated. property, Object the value to be associated with the specified property value)Associates the specified value with the specified property. |
| public abstract void | writeTo(OutputStream
the out)OutputStream object to which this SOAPMessage
object will be writtenWrites this |
| CHARACTER_SET_ENCODING | back to summary |
|---|---|
| public static final String CHARACTER_SET_ENCODING Specifies the character type encoding for the SOAP Message. Valid values include "utf-8" and "utf-16". See vendor documentation for additional supported values. The default is "utf-8".
| |
| WRITE_XML_DECLARATION | back to summary |
|---|---|
| public static final String WRITE_XML_DECLARATION Specifies whether the SOAP Message will contain an XML declaration when it is sent. The only valid values are "true" and "false". The default is "false".
| |
| SOAPMessage | back to summary |
|---|---|
| protected SOAPMessage() Default constructor. | |
| addAttachmentPart | back to summary |
|---|---|
| public abstract void addAttachmentPart(AttachmentPart attachmentPart) Adds the given
| |
| countAttachments | back to summary |
|---|---|
| public abstract int countAttachments() Gets a count of the number of attachments in this message. This count does not include the SOAP part.
| |
| createAttachmentPart | back to summary |
|---|---|
| public abstract AttachmentPart createAttachmentPart() Creates a new empty
| |
| createAttachmentPart | back to summary |
|---|---|
| public AttachmentPart createAttachmentPart(DataHandler dataHandler) Creates an
| |
| createAttachmentPart | back to summary |
|---|---|
| public AttachmentPart createAttachmentPart(Object content, String contentType) Creates an
| |
| getAttachment | back to summary |
|---|---|
| public abstract AttachmentPart getAttachment(SOAPElement element) throws SOAPException Returns an
| |
| getAttachments | back to summary |
|---|---|
| public abstract Iterator Retrieves all the
| |
| getAttachments | back to summary |
|---|---|
| public abstract Iterator Retrieves all the
| |
| getContentDescription | back to summary |
|---|---|
| public abstract String getContentDescription() Retrieves a description of this
| |
| getMimeHeaders | back to summary |
|---|---|
| public abstract MimeHeaders getMimeHeaders() Returns all the transport-specific MIME headers for this
| |
| getProperty | back to summary |
|---|---|
| public Object getProperty(String property) throws SOAPException Retrieves value of the specified property.
| |
| getSOAPBody | back to summary |
|---|---|
| public SOAPBody getSOAPBody() throws SOAPException Gets the SOAP Body contained in this
| |
| getSOAPHeader | back to summary |
|---|---|
| public SOAPHeader getSOAPHeader() throws SOAPException Gets the SOAP Header contained in this
| |
| getSOAPPart | back to summary |
|---|---|
| public abstract SOAPPart getSOAPPart() Gets the SOAP part of this
| |
| removeAllAttachments | back to summary |
|---|---|
| public abstract void removeAllAttachments() Removes all This method does not touch the SOAP part. | |
| removeAttachments | back to summary |
|---|---|
| public abstract void removeAttachments(MimeHeaders headers) Removes all the
| |
| saveChanges | back to summary |
|---|---|
| public abstract void saveChanges() throws SOAPException Updates this
In addition, this method marks the point at which the data from all
constituent
| |
| saveRequired | back to summary |
|---|---|
| public abstract boolean saveRequired() Indicates whether this
| |
| setContentDescription | back to summary |
|---|---|
| public abstract void setContentDescription(String description) Sets the description of this
| |
| setProperty | back to summary |
|---|---|
| public void setProperty(String property, Object value) throws SOAPException Associates the specified value with the specified property. If there was already a value associated with this property, the old value is replaced.
The valid property names include
Setting the property
The property Some implementations may allow encodings in addition to UTF-8 and UTF-16. Refer to your vendor's documentation for details.
| |
| writeTo | back to summary |
|---|---|
| public abstract void writeTo(OutputStream out) throws SOAPException, IOException Writes this
If there are no attachments, just an XML stream is written out. For
those messages that have attachments, Note that this method does not write the transport-specific MIME Headers of the Message
| |