Class JAXBMessage

    • Constructor Detail

      • JAXBMessage

        public JAXBMessage​(JAXBMessage that)
        Copy constructor.
    • Method Detail

      • create

        public static Message create​(BindingContext context,
                                     Object jaxbObject,
                                     SOAPVersion soapVersion)
        Creates a Message backed by a JAXB bean.
        Parameters:
        context - The JAXBContext to be used for marshalling.
        jaxbObject - The JAXB object that represents the payload. must not be null. This object must be bound to an element (which means it either is a JAXBElement or an instanceof a class with XmlRootElement).
        soapVersion - The SOAP version of the message. Must not be null.
      • create

        public static Message create​(jakarta.xml.bind.JAXBContext context,
                                     Object jaxbObject,
                                     SOAPVersion soapVersion)
        Deprecated.
      • createRaw

        public static Message createRaw​(jakarta.xml.bind.JAXBContext context,
                                        Object jaxbObject,
                                        SOAPVersion soapVersion)
        Deprecated.
        For use when creating a Dispatch object with an unknown JAXB implementation for he JAXBContext parameter.
      • create

        public static Message create​(XMLBridge bridge,
                                     Object jaxbObject,
                                     SOAPVersion soapVer)
        Creates a Message backed by a JAXB bean.
        Parameters:
        bridge - Specify the payload tag name and how jaxbObject is bound.
        jaxbObject -
      • 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

        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.
      • getPayloadLocalPart

        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
      • 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.
        Overrides:
        readPayloadAsJAXB in class AbstractMessageImpl
        Throws:
        jakarta.xml.bind.JAXBException - If JAXB reports an error during the processing.
      • writePayloadTo

        protected void writePayloadTo​(ContentHandler contentHandler,
                                      ErrorHandler errorHandler,
                                      boolean fragment)
                               throws SAXException
        Writes the payload as SAX events.
        Specified by:
        writePayloadTo in class AbstractMessageImpl
        fragment - 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

        public Message copy()
        Description copied from class: Message
        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.

        1. 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.
        2. 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 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.

        IMPORTANT

        WHEN YOU IMPLEMENT OR CHANGE A Message.copy() METHOD, YOU MUST USE THE Message.copyFrom(com.sun.xml.ws.api.message.Message) METHOD IN THE IMPLEMENTATION.

        Specified by:
        copy in class Message