Class MessageWrapper
- Author:
- K.Venugopal@sun.com
-
Field Summary
Fields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet -
Constructor Summary
ConstructorsConstructorDescriptionMessageWrapper(com.sun.xml.stream.buffer.MutableXMLStreamBuffer msg, boolean oneWay, com.sun.xml.ws.api.message.MessageHeaders hdrs, SecuredMessage sm) MessageWrapper(SecuredMessage sm, boolean oneWay) -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of a Message.com.sun.xml.ws.api.message.AttachmentSetGets the attachments of this message (attachments live outside a message.)com.sun.xml.ws.api.message.HeaderListGets all the headers of this message.Gets the local name of the payload element.Gets the namespace URI of the payload element.protected booleanOptimization hint for the derived class to check if we may have some attachments.booleanReturns true if headers are present in the message.booleanReturns true if a Message has a payload.booleanisFault()Returns true if this message is a fault.booleanisOneWay(com.sun.xml.ws.api.model.wsdl.WSDLPort port) Returns true if this message is a request message for a one way operation according to the given WSDL.javax.xml.soap.SOAPMessageCreates the equivalentSOAPMessagefrom this message.Consumes this message including the envelope.Reads the payload as aXMLStreamReaderThis consumes the message.<T> TreadPayloadAsJAXB(com.sun.xml.bind.api.Bridge<T> bridge) Reads the payload as a JAXB object according to the givenBridge.<T> TreadPayloadAsJAXB(com.sun.xml.ws.spi.db.XMLBridge<T> arg0) <T> TreadPayloadAsJAXB(javax.xml.bind.Unmarshaller unmarshaller) Reads the payload as a JAXB object by using the given unmarshaller.Returns the payload as aSourceobject.voidWrites the payload to StAX.voidWrites the whole SOAP message (but not attachments) to the given writer.voidwriteTo(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, getSOAPVersion, getTransportHeaders, getTransportHeaders, readAsSOAPMessage, setMessageMedadata
-
Constructor Details
-
MessageWrapper
-
MessageWrapper
public MessageWrapper(com.sun.xml.stream.buffer.MutableXMLStreamBuffer msg, boolean oneWay, com.sun.xml.ws.api.message.MessageHeaders hdrs, SecuredMessage sm)
-
-
Method Details
-
hasHeaders
public boolean hasHeaders()Returns true if headers are present in the message.- Specified by:
hasHeadersin classcom.sun.xml.ws.api.message.Message- Returns:
- true if headers are present.
-
getHeaders
public com.sun.xml.ws.api.message.HeaderList getHeaders()Gets all the headers of this message.Implementation Note
Message implementation is allowed to defer the construction of
MessageHeadersobject. So if you only want to check for the existence of any header element, usehasHeaders().- Specified by:
getHeadersin classcom.sun.xml.ws.api.message.Message- Returns:
- always return the same non-null object.
-
getAttachments
public com.sun.xml.ws.api.message.AttachmentSet getAttachments()Gets the attachments of this message (attachments live outside a message.)- Overrides:
getAttachmentsin classcom.sun.xml.ws.api.message.Message
-
hasAttachments
protected boolean hasAttachments()Optimization hint for the derived class to check if we may have some attachments.- Overrides:
hasAttachmentsin classcom.sun.xml.ws.api.message.Message
-
isOneWay
public boolean isOneWay(@NotNull com.sun.xml.ws.api.model.wsdl.WSDLPort port) 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:
isOneWayin classcom.sun.xml.ws.api.message.Message- Parameters:
port- Messages are always created under the context of oneWSDLPortand they never go outside that context. Pass in that "governing"WSDLPortobject here. We chose to receive this as a parameter instead of keepingWSDLPortin 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
WSDLPortobjects, which is a bug of the caller.
-
getPayloadLocalPart
Gets the local name of the payload element.- Specified by:
getPayloadLocalPartin classcom.sun.xml.ws.api.message.Message- Returns:
- null if a Message doesn't have any payload.
-
isFault
public boolean isFault()Returns true if this message is a fault.Just a convenience method built on
getPayloadNamespaceURI()andgetPayloadLocalPart().- Overrides:
isFaultin classcom.sun.xml.ws.api.message.Message
-
getPayloadNamespaceURI
Gets the namespace URI of the payload element.- Specified by:
getPayloadNamespaceURIin classcom.sun.xml.ws.api.message.Message- Returns:
- null if a Message doesn't have any payload.
-
hasPayload
public boolean hasPayload()Returns true if a Message has a payload.A message without a payload is a SOAP message that looks like:
<xmp> <S:Envelope> <S:Header> ... </S:Header> <S:Body /> </S:Envelope> </xmp>- Specified by:
hasPayloadin classcom.sun.xml.ws.api.message.Message
-
readEnvelopeAsSource
Consumes this message including the envelope. returns it as aSourceobject.- Specified by:
readEnvelopeAsSourcein classcom.sun.xml.ws.api.message.Message
-
readPayloadAsSource
Returns the payload as aSourceobject. This consumes the message.- Specified by:
readPayloadAsSourcein classcom.sun.xml.ws.api.message.Message- Returns:
- if there's no payload, this method returns null.
-
readAsSOAPMessage
public javax.xml.soap.SOAPMessage readAsSOAPMessage() throws javax.xml.soap.SOAPExceptionCreates the equivalentSOAPMessagefrom this message. This consumes the message.- Specified by:
readAsSOAPMessagein classcom.sun.xml.ws.api.message.Message- Throws:
javax.xml.soap.SOAPException- if there's any error while creating aSOAPMessage.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(javax.xml.bind.Unmarshaller unmarshaller) throws javax.xml.bind.JAXBException Reads the payload as a JAXB object by using the given unmarshaller. This consumes the message.- Specified by:
readPayloadAsJAXBin classcom.sun.xml.ws.api.message.Message- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(com.sun.xml.bind.api.Bridge<T> bridge) throws javax.xml.bind.JAXBException Reads the payload as a JAXB object according to the givenBridge. This consumes the message.- Specified by:
readPayloadAsJAXBin classcom.sun.xml.ws.api.message.Message- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
readPayload
Reads the payload as aXMLStreamReaderThis consumes the message.- Specified by:
readPayloadin classcom.sun.xml.ws.api.message.Message- Returns:
- If there's no payload, this method returns null.
Otherwise always non-null valid
XMLStreamReaderthat points to the payload tag name. - Throws:
XMLStreamException
-
writePayloadTo
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:
writePayloadToin classcom.sun.xml.ws.api.message.Message- Throws:
XMLStreamException- If theXMLStreamWriterreports an error, or some other errors happen during the processing.
-
writeTo
Writes the whole SOAP message (but not attachments) to the given writer. This consumes the message.- Specified by:
writeToin classcom.sun.xml.ws.api.message.Message- Throws:
XMLStreamException- If theXMLStreamWriterreports an error, or some other errors happen during the processing.
-
writeTo
Writes the whole SOAP envelope as SAX events.This consumes the message.
- Specified by:
writeToin classcom.sun.xml.ws.api.message.Message- 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 as SAXParseException.SAXExceptions thrown fromErrorHandlershould propagate directly through this method.- Throws:
SAXException
-
copy
Creates a copy of a Message.This method creates a new Message whose header/payload/attachments/properties are identical to this Message. Once created, the created Message and the original Message behaves independently --- adding header/ attachment to one Message doesn't affect another Message 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 Messages 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 idential copy of a Message.
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.
- Specified by:
copyin classcom.sun.xml.ws.api.message.Message
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(com.sun.xml.ws.spi.db.XMLBridge<T> arg0) throws javax.xml.bind.JAXBException - Specified by:
readPayloadAsJAXBin classcom.sun.xml.ws.api.message.Message- Throws:
javax.xml.bind.JAXBException
-