LibraryToggle FramesPrintFeedback

How the handleMessage() method completes its message processing has a direct impact on how message processing proceeds. It can complete by doing one of the following actions:

  1. return true—Returning true signals to the Fuse Services Framework runtime that message processing should continue normally. The next handler, if any, has its handleMessage() invoked.

  2. return false—Returning false signals to the Fuse Services Framework runtime that normal message processing is to stop. How the runtime proceeds depends on the message exchange pattern in use for the current message.

    For request-response message exchanges the following happens:

    For one-way message exchanges the following happens:

  3. throw a ProtocolException exception—Throwing a ProtocolException exception, or a subclass of this exception, signals the Fuse Services Framework runtime that fault message processing is to start. How the runtime proceeds depends on the message exchange pattern in use for the current message.

    For request-response message exchanges the following happens:

    For one-way message exchanges the following happens:

  4. throw any other runtime exception—Throwing a runtime exception other than a ProtocolException exception signals the Fuse Services Framework runtime that message processing is to stop. All previously invoked message handlers have the close() method invoked and the exception is dispatched. If the message is part of a request-response message exchange the exception is dispatched so that it is returned to the consumer that originated the request.

Example 21.12 shows a handleMessage() implementation that prints the SOAP message to the screen.

Example 21.12. Handling a Message in a SOAP Handler

public boolean handleMessage(SOAPMessageContext smc)
{
  PrintStream out;

  Boolean outbound = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); 1

  if (outbound.booleanValue()) 2
  {
    out.println("\nOutbound message:");
  }
  else
  {
    out.println("\nInbound message:");
  }

  SOAPMessage message = smc.getMessage(); 3

  message.writeTo(out); 4
  out.println();

  return true;
}

The code in Example 21.12 does the following:

1

Retrieves the outbound property from the message context.

2

Tests the messages direction and prints the appropriate message.

3

Retrieves the SOAP message from the context.

4

Prints the message to the console.

Comments powered by Disqus
loading table of contents...