LibraryToggle FramesPrintFeedback

The direction of a message can be determined by querying the message exchange. The message exchange stores the inbound message and the outbound message in separate properties.[1]

The message exchange associated with a message is retrieved using the message's getExchange() method. As shown in Example 4.1, getExchange() does not take any parameters and returns the message exchange as a org.apache.cxf.message.Exchange object.


The Exchange object has four methods, shown in Example 4.2, for getting the messages associated with an exchange. Each method will either return the message as a org.apache.cxf.Message object or it will return null if the message does not exist.


Example 4.3 shows code for determining if the current message is outbound. The method gets the message exchange and checks to see if the current message is the same as the exchange's outbound message. It also checks the current message against the exchanges outbound fault message to error messages on the outbound fault interceptor chain.




[1] It also stores inbound and outbound faults separately.

Comments powered by Disqus