- Direct Known Subclasses:
FaultMessage
FilterMessageImpl
contains some other Message, which it uses
as its basic source of message data, possibly transforming the data along
the way or providing additional functionality.
The class FilterMessageImpl
itself simply overrides
all the methods of Message
and invokes them on
contained Message delegate. Subclasses of FilterMessageImpl
may further override some of these methods and may also provide
additional methods and fields.
- Author:
- Jitendra Kotamraju
-
Field Summary
Fields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
consume()
Marks the message as consumed, without actually reading the contents.copy()
Creates a copy of aMessage
.Gets the attachments of this message (attachments live outside a message.)It gives S:Envelope/S:Body/S:Fault/detail 's first child's name.Gets all the headers of this message.getID
(AddressingVersion av, SOAPVersion sv) Retuns a unique id for the message.Retuns a unique id for the message.Gets the local name of the payload element.Gets the namespace URI of the payload element.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.boolean
isFault()
Returns true if this message is a fault.boolean
Returns true if this message is a request message for a one way operation according to the given WSDL.jakarta.xml.soap.SOAPMessage
Creates the equivalentSOAPMessage
from this message.jakarta.xml.soap.SOAPMessage
readAsSOAPMessage
(Packet packet, boolean inbound) Creates the equivalentSOAPMessage
from this message.Consumes this message including the envelope.Reads the payload as aXMLStreamReader
This consumes the message.<T> T
readPayloadAsJAXB
(XMLBridge<T> bridge) Reads the payload as a Data-Bond object This consumes the message.<T> T
readPayloadAsJAXB
(jakarta.xml.bind.Unmarshaller unmarshaller) Reads the payload as a JAXB object by using the given unmarshaller.Returns the payload as aSource
object.void
Writes the payload to StAX.void
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, copyFrom, generateMessageID, getMethod, getOperation, getOperation, getTransportHeaders, getTransportHeaders, setMessageMedadata
-
Constructor Details
-
FilterMessageImpl
-
-
Method Details
-
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
Description copied from class:Message
Gets the attachments of this message (attachments live outside a message.)- Overrides:
getAttachments
in classMessage
-
hasAttachments
protected boolean hasAttachments()Description copied from class:Message
Optimization hint for the derived class to check if we may have some attachments.- Overrides:
hasAttachments
in classMessage
-
isOneWay
Description copied from class:Message
Returns true if this message is a request message for a one way operation according to the given WSDL. False otherwise.This method is functionally equivalent as doing
getOperation(port).getOperation().isOneWay()
(with proper null check and all.) But this method can sometimes work faster than that (for example, on the client side when used with SEI.)- Overrides:
isOneWay
in classMessage
- Parameters:
port
-Message
s are always created under the context of oneWSDLPort
and they never go outside that context. Pass in that "governing"WSDLPort
object here. We chose to receive this as a parameter instead of keepingWSDLPort
in a message, just to save the storage.The implementation of this method involves caching the return value, so the behavior is undefined if multiple callers provide different
WSDLPort
objects, which is a bug of the caller.
-
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
-
isFault
public boolean isFault()Description copied from class:Message
Returns true if this message is a fault.Just a convenience method built on
Message.getPayloadNamespaceURI()
andMessage.getPayloadLocalPart()
. -
getFirstDetailEntryName
Description copied from class:Message
It gives S:Envelope/S:Body/S:Fault/detail 's first child's name. Should be called for messages that have SOAP Fault.This implementation is expensive so concrete implementations are expected to override this one.
- Overrides:
getFirstDetailEntryName
in classMessage
- Returns:
- first detail entry's name, if there is one else null
-
readEnvelopeAsSource
Description copied from class:Message
Consumes this message including the envelope. returns it as aSource
object.- Specified by:
readEnvelopeAsSource
in classMessage
-
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.
-
readAsSOAPMessage
public jakarta.xml.soap.SOAPMessage readAsSOAPMessage() throws jakarta.xml.soap.SOAPExceptionDescription copied from class:Message
Creates the equivalentSOAPMessage
from this message. This consumes the message.- Specified by:
readAsSOAPMessage
in classMessage
- Throws:
jakarta.xml.soap.SOAPException
- if there's any error while creating aSOAPMessage
.
-
readAsSOAPMessage
public jakarta.xml.soap.SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws jakarta.xml.soap.SOAPException Description copied from class:Message
Creates the equivalentSOAPMessage
from this message. It also uses transport specific headers from Packet during the SOAPMessage construction so thatSOAPMessage.getMimeHeaders()
gives meaningful transport headers. This consumes the message.- Overrides:
readAsSOAPMessage
in classMessage
- Throws:
jakarta.xml.soap.SOAPException
- if there's any error while creating aSOAPMessage
.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(jakarta.xml.bind.Unmarshaller unmarshaller) throws jakarta.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:
jakarta.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:
jakarta.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
-
consume
public void consume()Description copied from class:Message
Marks the message as consumed, without actually reading the contents.This method provides an opportunity for implementations to reuse any reusable resources needed for representing the payload.
This method may not be called more than once since it may have released the reusable resources.
-
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
Description copied from class:Message
Creates a copy of aMessage
.This method creates a new
Message
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.This method does NOT consume a message.
To enable efficient copy operations, there's a few restrictions on how copied message can be used.
- The original and the copy may not be
used concurrently by two threads (this allows two
Message
s to share some internal resources, such as JAXB marshallers.) Note that it's OK for the original and the copy to be processed by two threads, as long as they are not concurrent. - The copy has the same 'life scope'
as the original (this allows shallower copy, such as
JAXB beans wrapped in
JAXBMessage
.)
A 'life scope' of a message created during a message processing in a pipeline is until a pipeline processes the next message. A message cannot be kept beyond its life scope. (This experimental design is to allow message objects to be reused --- feedback appreciated.)
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 identical copy of aMessage
.The actual copy operation depends on the layout of the data in memory, hence it's best to be done by the
Message
implementation itself.The restrictions placed on the use of copied
Message
can be relaxed if necessary, but it will make the copy method more expensive.IMPORTANT
WHEN YOU IMPLEMENT OR CHANGE A
#copy()
METHOD, YOU MUST USE THEMessage.copyFrom(com.sun.xml.ws.api.message.Message)
METHOD IN THE IMPLEMENTATION. - The original and the copy may not be
used concurrently by two threads (this allows two
-
getID
Description copied from class:Message
Retuns a unique id for the message. The id can be used for various things, like debug assistance, logging, and MIME encoding(say for boundary).This method will check the existence of the addressing
<MessageID>
header, and if present uses that value. Otherwise it generates one from UUID.random(), and return it without adding a new header. But it doesn't add a<MessageID>
to the header list since we expect them to be added before calling this method.Addressing tube will go do a separate verification on inbound headers to make sure that
<MessageID>
header is present when it's supposed to be.- Overrides:
getID
in classMessage
- Parameters:
binding
- object created byBindingID.createBinding()
- Returns:
- unique id for the message
-
getID
Description copied from class:Message
Retuns a unique id for the message. -
getSOAPVersion
- Overrides:
getSOAPVersion
in classMessage
-