Class VerifiedStreamMessage
Message implementation backed by XMLStreamReader.
TODO: we need another message class that keeps XMLStreamReader that points
at the start of the envelope element.-
Field Summary
Fields inherited from class com.sun.xml.ws.message.AbstractMessageImpl
EMPTY_ATTS, NULL_LOCATOR, soapVersionFields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet -
Constructor Summary
ConstructorsConstructorDescriptionVerifiedStreamMessage(MessageHeaders headers, AttachmentSet attachmentSet, XMLStreamReader reader, SOAPVersion soapVersion, Map<String, String> bodyEnvNs) Creates aStreamMessagefrom aXMLStreamReaderthat points at the start element of the payload, and headers.VerifiedStreamMessage(TagInfoset envelopeTag, TagInfoset headerTag, AttachmentSet attachmentSet, MessageHeaders headers, TagInfoset bodyTag, XMLStreamReader reader, SOAPVersion soapVersion, Map<String, String> bodyEnvNs) Creates aStreamMessagefrom aXMLStreamReaderand the complete infoset of the SOAP envelope. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume()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.)Gets all the headers of this message.Gets the local name of the payload element.Gets the namespace URI of the payload element.booleanReturns true if headers are present in the message.booleanReturns true if aMessagehas a payload.javax.xml.soap.SOAPMessageDefault implementation that usesAbstractMessageImpl.writeTo(ContentHandler, ErrorHandler)Reads the payload as aXMLStreamReaderThis consumes the message.<T> TreadPayloadAsJAXB(Bridge<T> bridge) Reads the payload as a JAXB object according to the givenBridge.<T> TreadPayloadAsJAXB(javax.xml.bind.Unmarshaller unmarshaller) Reads the payload as a JAXB object by using the given unmarshaller.Returns the payload as aSourceobject.voidwritePayloadTo(XMLStreamWriter writer) Writes the payload to StAX.voidwritePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) Writes the payload to SAX events.voidDefault implementation that relies onMessage.writePayloadTo(XMLStreamWriter)voidwriteTo(ContentHandler contentHandler, ErrorHandler errorHandler) Writes the whole envelope as SAX events.Methods inherited from class com.sun.xml.ws.message.AbstractMessageImpl
getSOAPVersion, readAsSOAPMessage, readEnvelopeAsSource, readPayloadAsJAXB, toSAAJ, writeToBodyStartMethods inherited from class com.sun.xml.ws.api.message.Message
addSOAPMimeHeaders, assertOneWay, copyFrom, generateMessageID, getFirstDetailEntryName, getID, getID, getMethod, getOperation, getOperation, getTransportHeaders, getTransportHeaders, hasAttachments, isFault, isOneWay, setMessageMedadata
-
Constructor Details
-
VerifiedStreamMessage
public VerifiedStreamMessage(@Nullable MessageHeaders headers, @NotNull AttachmentSet attachmentSet, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion, Map<String, String> bodyEnvNs) Creates aStreamMessagefrom aXMLStreamReaderthat points at the start element of the payload, and headers.This method creaets a
Messagefrom a payload.- Parameters:
headers- if null, it means no headers. if non-null, it will be owned by this message.reader- points at the start element/document of the payload (or the end element of the <s:Body> if there's no payload)
-
VerifiedStreamMessage
public VerifiedStreamMessage(@NotNull TagInfoset envelopeTag, @Nullable TagInfoset headerTag, @NotNull AttachmentSet attachmentSet, @Nullable MessageHeaders headers, @NotNull TagInfoset bodyTag, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion, Map<String, String> bodyEnvNs) Creates aStreamMessagefrom aXMLStreamReaderand the complete infoset of the SOAP envelope.See #StreamMessage(MessageHeaders, AttachmentSet, XMLStreamReader, SOAPVersion) for the description of the basic parameters.
- Parameters:
headerTag- Null if the message didn't have a header tag.
-
-
Method Details
-
hasHeaders
public boolean hasHeaders()Description copied from class:MessageReturns true if headers are present in the message.- Specified by:
hasHeadersin classMessage- Returns:
- true if headers are present.
-
getHeaders
Description copied from class:MessageGets all the headers of this message.Implementation Note
Messageimplementation is allowed to defer the construction ofMessageHeadersobject. So if you only want to check for the existence of any header element, useMessage.hasHeaders().- Specified by:
getHeadersin classMessage- Returns:
- always return the same non-null object.
-
getAttachments
Description copied from class:MessageGets the attachments of this message (attachments live outside a message.)- Overrides:
getAttachmentsin classMessage
-
getPayloadLocalPart
Description copied from class:MessageGets the local name of the payload element.- Specified by:
getPayloadLocalPartin classMessage- Returns:
- null if a
Messagedoesn't have any payload.
-
getPayloadNamespaceURI
Description copied from class:MessageGets the namespace URI of the payload element.- Specified by:
getPayloadNamespaceURIin classMessage- Returns:
- null if a
Messagedoesn't have any payload.
-
hasPayload
public boolean hasPayload()Description copied from class:MessageReturns true if aMessagehas 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:
hasPayloadin classMessage
-
readPayloadAsSource
Description copied from class:MessageReturns the payload as aSourceobject. This consumes the message.- Specified by:
readPayloadAsSourcein 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:MessageReads the payload as a JAXB object by using the given unmarshaller. This consumes the message.- Overrides:
readPayloadAsJAXBin classAbstractMessageImpl- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
Description copied from class:MessageReads the payload as a JAXB object according to the givenBridge. This consumes the message.- Overrides:
readPayloadAsJAXBin classAbstractMessageImpl- Returns:
- null if there's no payload.
- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
consume
public void consume()Description copied from class:MessageMarks 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.
-
readPayload
Description copied from class:MessageReads the payload as aXMLStreamReaderThis consumes the message. The caller is encouraged to callXMLStreamReaderFactory.recycle(XMLStreamReader)when finished using the instance.- Specified by:
readPayloadin classMessage- Returns:
- If there's no payload, this method returns null.
Otherwise always non-null valid
XMLStreamReaderthat points to the payload tag name.
-
writePayloadTo
Description copied from class:MessageWrites 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 classMessage- Throws:
XMLStreamException- If theXMLStreamWriterreports an error, or some other errors happen during the processing.
-
writeTo
Description copied from class:AbstractMessageImplDefault implementation that relies onMessage.writePayloadTo(XMLStreamWriter)- Overrides:
writeToin classAbstractMessageImpl- Throws:
XMLStreamException- If theXMLStreamWriterreports an error, or some other errors happen during the processing.
-
writePayloadTo
public void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException Description copied from class:AbstractMessageImplWrites the payload to SAX events.- Specified by:
writePayloadToin classAbstractMessageImplfragment- if true, this method will fire SAX events without start/endDocument events, suitable for embedding this into a bigger SAX event sequence. if false, this method generaets a completely SAX event sequence on its own.- Throws:
SAXException
-
copy
Description copied from class:MessageCreates a copy of aMessage.This method creates a new
Messagewhose header/payload/attachments/properties are identical to thisMessage. Once created, the createdMessageand the originalMessagebehaves independently --- adding header/ attachment to oneMessagedoesn't affect anotherMessageat 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
Messagebody 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
Messageimplementation itself.The restrictions placed on the use of copied
Messagecan be relaxed if necessary, but it will make the copy method more expensive.IMPORTANT
WHEN YOU IMPLEMENT OR CHANGE A
Message.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
-
readAsSOAPMessage
public javax.xml.soap.SOAPMessage readAsSOAPMessage() throws javax.xml.soap.SOAPExceptionDescription copied from class:AbstractMessageImplDefault implementation that usesAbstractMessageImpl.writeTo(ContentHandler, ErrorHandler)- Overrides:
readAsSOAPMessagein classAbstractMessageImpl- Throws:
javax.xml.soap.SOAPException- if there's any error while creating aSOAPMessage.
-
writeTo
Description copied from class:AbstractMessageImplWrites the whole envelope as SAX events.- Overrides:
writeToin classAbstractMessageImpl- 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.SAXExceptions thrown fromErrorHandlershould propagate directly through this method.- Throws:
SAXException
-