SOAP Handler

JWS provides a handler framework that helps application code to inspect and manipulate outgoing and incoming SOAP messages. To inject a handler into the framework create a handler class and place it within a handler chain. The handler class should implement the javax.xml.ws.handler.Handler.

There are two subInterfaces of the Handler interface: LogicalHandler and SOAPHandler. The LogicalHandler is protocol-neutral and the SOAPHandler is SOAP-specific. A LogicalHandler has access only to the message payload in the SOAP body, and a SOAPHandler has access to the entire SOAP message, including any optional headers and attachments.

Methods of the Handler interface:

  • handleMessage
  • handleFault
  • close

SOAPHandler interface adds one additional method: getHeaders.

Handler Interface Photo

For an outbound message first are executed LogicalHandler methods. And for an inbound message - SOAPHandler methods. The runtime ordering makes sense because the LogicalHandler has access only to the body of the SOAP message, whereas the SOAPHandler has access to the entire SOAP message. For an outgoing message, then, the logical handlers should be able to process the payload, the SOAP body, before the SOAP handlers process the entire SOAP message.

LogicalHandler should be used instead of SOAPHandler if the application does not need to process SOAP headers or SOAP attachments.

Trustpilot
Trustpilot
Comments