Package com.sun.xml.ws.message.saaj
Class SAAJMessage
java.lang.Object
com.sun.xml.ws.api.message.Message
com.sun.xml.ws.message.saaj.SAAJMessage
Message
implementation backed by SOAPMessage
.- Author:
- Vivek Pandey, Rama Pulavarthi
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
AttachmentSet
for SAAJ. -
Field Summary
Fields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
access()
copy()
Creates a copy of aMessage
.protected XMLStreamReader
createXMLStreamReader
(javax.xml.soap.SOAPElement soapElement) Gets the attachments of this message (attachments live outside a message.)Gets all the headers of this message.Gets the local name of the payload element.Gets the namespace URI of the payload element.protected XMLStreamReader
getXMLStreamReader
(javax.xml.soap.SOAPElement soapElement) This allow the subclass to retain the XMLStreamReader.protected boolean
Optimization hint for the derived class to check if we may have some attachments.boolean
Returns true if headers are present in the message.boolean
Returns true if aMessage
has a payload.javax.xml.soap.SOAPMessage
Creates the equivalentSOAPMessage
from this message.Consumes this message including the envelope.Reads the payload as aXMLStreamReader
This consumes the message.<T> T
readPayloadAsJAXB
(Bridge<T> bridge) Deprecated.<T> T
readPayloadAsJAXB
(XMLBridge<T> bridge) Reads the payload as a Data-Bond object This consumes the message.<T> T
readPayloadAsJAXB
(javax.xml.bind.Unmarshaller unmarshaller) Reads the payload as a JAXB object by using the given unmarshaller.Returns the payload as aSource
object.protected XMLStreamReader
void
Writes the payload to StAX.void
writeTo
(XMLStreamWriter writer) Writes the whole SOAP message (but not attachments) to the given writer.void
writeTo
(ContentHandler contentHandler, ErrorHandler errorHandler) Writes the whole SOAP envelope as SAX events.Methods inherited from class com.sun.xml.ws.api.message.Message
addSOAPMimeHeaders, assertOneWay, consume, copyFrom, generateMessageID, getFirstDetailEntryName, getID, getID, getMethod, getOperation, getOperation, getTransportHeaders, getTransportHeaders, isFault, isOneWay, readAsSOAPMessage, setMessageMedadata
-
Constructor Details
-
SAAJMessage
public SAAJMessage(javax.xml.soap.SOAPMessage sm)
-
-
Method Details
-
access
protected void access() -
hasHeaders
public boolean hasHeaders()Description copied from class:Message
Returns true if headers are present in the message.- Specified by:
hasHeaders
in classMessage
- Returns:
- true if headers are present.
-
getHeaders
Description copied from class:Message
Gets all the headers of this message.Implementation Note
Message
implementation is allowed to defer the construction ofMessageHeaders
object. So if you only want to check for the existence of any header element, useMessage.hasHeaders()
.- Specified by:
getHeaders
in classMessage
- Returns:
- always return the same non-null object.
-
getAttachments
Gets the attachments of this message (attachments live outside a message.)- Overrides:
getAttachments
in classMessage
-
hasAttachments
protected boolean hasAttachments()Optimization hint for the derived class to check if we may have some attachments.- Overrides:
hasAttachments
in classMessage
-
getPayloadLocalPart
Description copied from class:Message
Gets the local name of the payload element.- Specified by:
getPayloadLocalPart
in classMessage
- Returns:
- null if a
Message
doesn't have any payload.
-
getPayloadNamespaceURI
Description copied from class:Message
Gets the namespace URI of the payload element.- Specified by:
getPayloadNamespaceURI
in classMessage
- Returns:
- null if a
Message
doesn't have any payload.
-
hasPayload
public boolean hasPayload()Description copied from class:Message
Returns true if aMessage
has a payload.A message without a payload is a SOAP message that looks like:
<S:Envelope> <S:Header> ... </S:Header> <S:Body /> </S:Envelope>
- Specified by:
hasPayload
in classMessage
-
readEnvelopeAsSource
Description copied from class:Message
Consumes this message including the envelope. returns it as aSource
object.- Specified by:
readEnvelopeAsSource
in classMessage
-
readAsSOAPMessage
public javax.xml.soap.SOAPMessage readAsSOAPMessage() throws javax.xml.soap.SOAPExceptionDescription copied from class:Message
Creates the equivalentSOAPMessage
from this message. This consumes the message.- Specified by:
readAsSOAPMessage
in classMessage
- Throws:
javax.xml.soap.SOAPException
- if there's any error while creating aSOAPMessage
.
-
readPayloadAsSource
Description copied from class:Message
Returns the payload as aSource
object. This consumes the message.- Specified by:
readPayloadAsSource
in classMessage
- Returns:
- if there's no payload, this method returns null.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(javax.xml.bind.Unmarshaller unmarshaller) throws javax.xml.bind.JAXBException Description copied from class:Message
Reads the payload as a JAXB object by using the given unmarshaller. This consumes the message.- Specified by:
readPayloadAsJAXB
in classMessage
- Throws:
javax.xml.bind.JAXBException
- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
Deprecated.Description copied from class:Message
Reads the payload as a JAXB object according to the givenBridge
. This consumes the message.- Specified by:
readPayloadAsJAXB
in classMessage
- Returns:
- null if there's no payload.
- Throws:
javax.xml.bind.JAXBException
- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
Description copied from class:Message
Reads the payload as a Data-Bond object This consumes the message.- Specified by:
readPayloadAsJAXB
in classMessage
- Returns:
- null if there's no payload.
- Throws:
javax.xml.bind.JAXBException
- If JAXB reports an error during the processing.
-
readPayload
Description copied from class:Message
Reads the payload as aXMLStreamReader
This consumes the message. The caller is encouraged to callXMLStreamReaderFactory.recycle(XMLStreamReader)
when finished using the instance.- Specified by:
readPayload
in classMessage
- Returns:
- If there's no payload, this method returns null.
Otherwise always non-null valid
XMLStreamReader
that points to the payload tag name. - Throws:
XMLStreamException
-
writePayloadTo
Description copied from class:Message
Writes the payload to StAX. This method writes just the payload of the message to the writer. This consumes the message. The implementation will not writeXMLStreamWriter.writeStartDocument()
norXMLStreamWriter.writeEndDocument()
If there's no payload, this method is no-op.
- Specified by:
writePayloadTo
in classMessage
- Throws:
XMLStreamException
- If theXMLStreamWriter
reports an error, or some other errors happen during the processing.
-
writeTo
Description copied from class:Message
Writes the whole SOAP message (but not attachments) to the given writer. This consumes the message.- Specified by:
writeTo
in classMessage
- Throws:
XMLStreamException
- If theXMLStreamWriter
reports an error, or some other errors happen during the processing.
-
writeTo
Description copied from class:Message
Writes the whole SOAP envelope as SAX events.This consumes the message.
- Specified by:
writeTo
in classMessage
- Parameters:
contentHandler
- must not be nulll.errorHandler
- must not be null. any error encountered during the SAX event production must be first reported to this error handler. Fatal errors can be then thrown asSAXParseException
.SAXException
s thrown fromErrorHandler
should propagate directly through this method.- Throws:
SAXException
-
copy
Creates a copy of aMessage
.
This method creates a newMessage
whose header/payload/attachments/properties are identical to thisMessage
. Once created, the createdMessage
and the originalMessage
behaves independently --- adding header/ attachment to oneMessage
doesn't affect anotherMessage
at all.Design Rationale
Since a
Message
body is read-once, sometimes (such as when you do fail-over, or WS-RM) you need to create an idential copy of aMessage
.
The actual copy operation depends on the layout of the data in memory, hence it's best to be done by theMessage
implementation itself. -
getSOAPVersion
- Overrides:
getSOAPVersion
in classMessage
-
getXMLStreamReader
This allow the subclass to retain the XMLStreamReader. -
createXMLStreamReader
-
soapBodyFirstChildReader
-