Published: Wednesday, 9 June 2010
Last modified: Thursday, 12 March 2015

Apache CXF is a web services framework for Java. We’ve successfully developed clients (consumers) and services using it. The official website is at


Interceptors listen and act upon incoming or outgoing messages. The CXF library can be used as both client and server, so an outgoing message from a client may be considered in incoming message on the server.

AbstractPhaseInterceptor is the base class. Method handleMessage() must be implemented, and optionally handleFault() can be overridden. If there is a fault, then inside handleFault(), you can access details via

Exception exception = message.getContent(Exception.class);
Throwable cause = exception.getCause();

An example of an interceptor is a custom logger.

The phase must be chosen when the interceptor is constructed. Look at the Phase class for a valid phase name, and refer to the CXF Interceptors documentation for a description of the various phases.

Request and response objects

Get a handle on the request or response objects using the following snippet:


a maybe used for objects used for both request and response.