Viewing Inbound and Outbound Messages in CXF
When using CXF either as a client or to serve services, you can quickly get the wish to view the raw inbound and outbound messages sent and received. Turns out, it is rather easy to enable this. There are various ways to enable this, ranging from a pure programmatic approach, to various forms of configuration. I like the custom namespace spring bean config, which is nice and short:
Put the following in your cxf.xml configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
</beans>
This works for both clients and services, although the understanding of inbound and outbound swaps
What the above configuration does, is put an interceptor into CXF, that logs the raw in-/outbound messages through its logging API. As a standard, the logging API in CXF is JDK logging, but you can configure CXF to use Log4J logging instead. You will need to ensure, that at least INFO level logging has been enabled for these logger names:
- org.apache.cxf.interceptor.LoggingInInterceptor
- org.apache.cxf.interceptor.LoggingOutInterceptor
There is more information about this at the CXF documentation on configuration and debugging.
January 30, 2008
Tags: cxf, Java, logging Posted in: Programming

One Response
Tech Per » Blog Archive » Making CXF Log RuntimeExceptions From Server Implementations - July 9, 2008
[...] might also want to enable logging of inbound and outbound messages in cxf, which is done by enabling INFO on these [...]
Leave a Reply