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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSAAJMessage.SAAJAttachmentprotected static classSAAJMessage.SAAJAttachmentSetAttachmentSetfor SAAJ.
-
Field Summary
-
Fields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet
-
-
Constructor Summary
Constructors Constructor Description SAAJMessage(javax.xml.soap.SOAPMessage sm)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaccess()Messagecopy()Creates a copy of aMessage.protected XMLStreamReadercreateXMLStreamReader(javax.xml.soap.SOAPElement soapElement)AttachmentSetgetAttachments()Gets the attachments of this message (attachments live outside a message.)MessageHeadersgetHeaders()Gets all the headers of this message.StringgetPayloadLocalPart()Gets the local name of the payload element.StringgetPayloadNamespaceURI()Gets the namespace URI of the payload element.SOAPVersiongetSOAPVersion()protected XMLStreamReadergetXMLStreamReader(javax.xml.soap.SOAPElement soapElement)This allow the subclass to retain the XMLStreamReader.protected booleanhasAttachments()Optimization hint for the derived class to check if we may have some attachments.booleanhasHeaders()Returns true if headers are present in the message.booleanhasPayload()Returns true if aMessagehas a payload.javax.xml.soap.SOAPMessagereadAsSOAPMessage()Creates the equivalentSOAPMessagefrom this message.SourcereadEnvelopeAsSource()Consumes this message including the envelope.XMLStreamReaderreadPayload()Reads the payload as aXMLStreamReaderThis consumes the message.<T> TreadPayloadAsJAXB(Bridge<T> bridge)Deprecated.<T> TreadPayloadAsJAXB(XMLBridge<T> bridge)Reads the payload as a Data-Bond object This consumes the message.<T> TreadPayloadAsJAXB(javax.xml.bind.Unmarshaller unmarshaller)Reads the payload as a JAXB object by using the given unmarshaller.SourcereadPayloadAsSource()Returns the payload as aSourceobject.protected XMLStreamReadersoapBodyFirstChildReader()voidwritePayloadTo(XMLStreamWriter sw)Writes the payload to StAX.voidwriteTo(XMLStreamWriter writer)Writes 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, getTransportHeaders, getTransportHeaders, isFault, isOneWay, readAsSOAPMessage, setMessageMedadata
-
-
-
-
Method Detail
-
access
protected void access()
-
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
@NotNull public MessageHeaders 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
@NotNull public AttachmentSet getAttachments()
Gets the attachments of this message (attachments live outside a message.)- Overrides:
getAttachmentsin classMessage
-
hasAttachments
protected boolean hasAttachments()
Optimization hint for the derived class to check if we may have some attachments.- Overrides:
hasAttachmentsin classMessage
-
getPayloadLocalPart
@Nullable public String 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
public String 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
-
readEnvelopeAsSource
public Source readEnvelopeAsSource()
Description copied from class:MessageConsumes this message including the envelope. returns it as aSourceobject.- Specified by:
readEnvelopeAsSourcein classMessage
-
readAsSOAPMessage
public javax.xml.soap.SOAPMessage readAsSOAPMessage() throws javax.xml.soap.SOAPExceptionDescription copied from class:MessageCreates the equivalentSOAPMessagefrom this message. This consumes the message.- Specified by:
readAsSOAPMessagein classMessage- Throws:
javax.xml.soap.SOAPException- if there's any error while creating aSOAPMessage.
-
readPayloadAsSource
public Source 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.JAXBExceptionDescription copied from class:MessageReads the payload as a JAXB object by using the given unmarshaller. This consumes the message.- Specified by:
readPayloadAsJAXBin classMessage- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(Bridge<T> bridge) throws javax.xml.bind.JAXBException
Deprecated.Description copied from class:MessageReads the payload as a JAXB object according to the givenBridge. This consumes the message.- Specified by:
readPayloadAsJAXBin classMessage- Returns:
- null if there's no payload.
- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws javax.xml.bind.JAXBException
Description copied from class:MessageReads the payload as a Data-Bond object This consumes the message.- Specified by:
readPayloadAsJAXBin classMessage- Returns:
- null if there's no payload.
- Throws:
javax.xml.bind.JAXBException- If JAXB reports an error during the processing.
-
readPayload
public XMLStreamReader readPayload() throws XMLStreamException
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. - Throws:
XMLStreamException
-
writePayloadTo
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException
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
public void writeTo(XMLStreamWriter writer) throws XMLStreamException
Description copied from class:MessageWrites the whole SOAP message (but not attachments) to the given writer. This consumes the message.- Specified by:
writeToin classMessage- Throws:
XMLStreamException- If theXMLStreamWriterreports an error, or some other errors happen during the processing.
-
writeTo
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException
Description copied from class:MessageWrites the whole SOAP envelope as SAX events.This consumes the message.
- Specified by:
writeToin 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.SAXExceptions thrown fromErrorHandlershould propagate directly through this method.- Throws:
SAXException
-
copy
public Message copy()
Creates a copy of aMessage.
This method creates a newMessagewhose header/payload/attachments/properties are identical to thisMessage. Once created, the createdMessageand the originalMessagebehaves independently --- adding header/ attachment to oneMessagedoesn't affect anotherMessageat all.
Design Rationale
Since aMessagebody 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 theMessageimplementation itself.
-
getSOAPVersion
public SOAPVersion getSOAPVersion()
- Overrides:
getSOAPVersionin classMessage
-
getXMLStreamReader
protected XMLStreamReader getXMLStreamReader(javax.xml.soap.SOAPElement soapElement)
This allow the subclass to retain the XMLStreamReader.
-
createXMLStreamReader
protected XMLStreamReader createXMLStreamReader(javax.xml.soap.SOAPElement soapElement)
-
soapBodyFirstChildReader
protected XMLStreamReader soapBodyFirstChildReader()
-
-