SOAPHandler vs LogicalHandler

1.8k Views Asked by At

Can anybody explain, why do we need LogicalHandler if we can do much more with a SOAPHandler in JaxWs?

1

There are 1 best solutions below

0
Scott Heaberlin On

From the JAX-WS 2.2 spec:

JAX-WS 2.0 defines two types of handler:

Logical Handlers that only operate on message context properties and message payloads. Logical handlers are protocol agnostic and are unable to affect protocol specific parts of a message. Logical handlers are handlers that implement javax.xml.ws.handler.LogicalHandler. Protocol Handlers that operate on message context properties and protocol specific messages.

Protocol handlers are specific to a particular protocol and may access and change protocol specific aspects of a message. Protocol handlers are handlers that implement any interface derived from javax.xml.ws- .handler.Handler except javax.xml.ws.handler.LogicalHandler.

...

Handlers for protocols other than SOAP are expected to implement a protocol-specific interface that extends javax.xml.ws.handler.Handler.

So in short, if you need nothing to do with anything SOAP, you don't need to implement SOAPHandler. One use case might be a handler that only processes HTTP headers, attachments, or inspects the HttpServletRequest. Yes, you can do much more with SOAPHandler but sometimes you don't need access to SOAP headers, SOAPMessage, or payload DOM access.