Class SAAJMessage


  • public class SAAJMessage
    extends Message
    Message implementation backed by SOAPMessage.
    Author:
    Vivek Pandey, Rama Pulavarthi
    • Constructor Detail

      • SAAJMessage

        public SAAJMessage​(jakarta.xml.soap.SOAPMessage sm)
    • Method Detail

      • 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 class Message
        Returns:
        true if headers are present.
      • getHeaders

        @NotNull
        public MessageHeaders getHeaders()
        Description copied from class: Message
        Gets all the headers of this message.

        Implementation Note

        Message implementation is allowed to defer the construction of MessageHeaders object. So if you only want to check for the existence of any header element, use Message.hasHeaders().

        Specified by:
        getHeaders in class Message
        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:
        getAttachments in class Message
      • hasAttachments

        protected boolean hasAttachments()
        Optimization hint for the derived class to check if we may have some attachments.
        Overrides:
        hasAttachments in class Message
      • getPayloadLocalPart

        @Nullable
        public String getPayloadLocalPart()
        Description copied from class: Message
        Gets the local name of the payload element.
        Specified by:
        getPayloadLocalPart in class Message
        Returns:
        null if a Message doesn't have any payload.
      • getPayloadNamespaceURI

        public String getPayloadNamespaceURI()
        Description copied from class: Message
        Gets the namespace URI of the payload element.
        Specified by:
        getPayloadNamespaceURI in class Message
        Returns:
        null if a Message doesn't have any payload.
      • hasPayload

        public boolean hasPayload()
        Description copied from class: Message
        Returns true if a Message 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 class Message
      • readEnvelopeAsSource

        public Source readEnvelopeAsSource()
        Description copied from class: Message
        Consumes this message including the envelope. returns it as a Source object.
        Specified by:
        readEnvelopeAsSource in class Message
      • readAsSOAPMessage

        public jakarta.xml.soap.SOAPMessage readAsSOAPMessage()
                                                       throws jakarta.xml.soap.SOAPException
        Description copied from class: Message
        Creates the equivalent SOAPMessage from this message. This consumes the message.
        Specified by:
        readAsSOAPMessage in class Message
        Throws:
        jakarta.xml.soap.SOAPException - if there's any error while creating a SOAPMessage.
      • readPayloadAsSource

        public Source readPayloadAsSource()
        Description copied from class: Message
        Returns the payload as a Source object. This consumes the message.
        Specified by:
        readPayloadAsSource in class Message
        Returns:
        if there's no payload, this method returns null.
      • 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 class Message
        Throws:
        jakarta.xml.bind.JAXBException - If JAXB reports an error during the processing.
      • readPayloadAsJAXB

        public <T> T readPayloadAsJAXB​(org.glassfish.jaxb.runtime.api.Bridge<T> bridge)
                                throws jakarta.xml.bind.JAXBException
        Deprecated.
        Description copied from class: Message
        Reads the payload as a JAXB object according to the given Bridge. This consumes the message.
        Specified by:
        readPayloadAsJAXB in class Message
        Returns:
        null if there's no payload.
        Throws:
        jakarta.xml.bind.JAXBException - If JAXB reports an error during the processing.
      • readPayloadAsJAXB

        public <T> T readPayloadAsJAXB​(XMLBridge<T> bridge)
                                throws jakarta.xml.bind.JAXBException
        Description copied from class: Message
        Reads the payload as a Data-Bond object This consumes the message.
        Specified by:
        readPayloadAsJAXB in class Message
        Returns:
        null if there's no payload.
        Throws:
        jakarta.xml.bind.JAXBException - If JAXB reports an error during the processing.
      • writeTo

        public void writeTo​(ContentHandler contentHandler,
                            ErrorHandler errorHandler)
                     throws SAXException
        Description copied from class: Message
        Writes the whole SOAP envelope as SAX events.

        This consumes the message.

        Specified by:
        writeTo in class 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 from ErrorHandler should propagate directly through this method.
        Throws:
        SAXException
      • copy

        public Message 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.

        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.
        Specified by:
        copy in class Message
      • getXMLStreamReader

        protected XMLStreamReader getXMLStreamReader​(jakarta.xml.soap.SOAPElement soapElement)
        This allow the subclass to retain the XMLStreamReader.
      • createXMLStreamReader

        protected XMLStreamReader createXMLStreamReader​(jakarta.xml.soap.SOAPElement soapElement)
      • soapBodyFirstChildReader

        protected XMLStreamReader soapBodyFirstChildReader()