Debugging has been edited by Glen Mazza (Nov 14, 2007).

Change summary:

Client-side logging info added

(View changes)


Logging Messages

CXF includes two logging interceptors which output the incoming/outgoing messages to the Java log. To enable, you need to add these interceptors to your endpoint.

Server-side, if you have a JAX-WS endpoint, you would want to do this:

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;

EndpointImpl ep = (EndpointImpl) Endpoint.publish("http://localhost/service", service);

ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());

For client-side logging, the following code snippet can be used as an example:

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;

public class WSClient {
    public static void main (String[] args) {
        MyService ws = new MyService();
        MyPortType port = ws.getPort();
        Client client = ClientProxy.getClient(port);
        client.getInInterceptors().add(new LoggingInInterceptor());
        client.getOutInterceptors().add(new LoggingOutInterceptor()); 
        // make WS calls...

You can also enable message logging through CXF configuration.

Configure logging levels.

CXF uses Java SE Logging. In the /etc folder of the CXF distribution there is a sample file you can use to configure logging. For example, if you want to change the console logging level from WARNING to FINE, you need to update two properties in this file as below:

.level= FINE
java.util.logging.ConsoleHandler.level = FINE

Once this is done, you will need to set the -Djava.util.logging.config.file property to the location of the file. As an example, the Ant target below has this property set:

<target name="runClient">
   <java classname="client.WSClient" fork="true">	    	
         <pathelement location="${build.classes.dir}"/>
         <fileset dir="${env.CXF_HOME}/lib">
            <include name="*.jar"/>
      <jvmarg value="-Djava.util.logging.config.file=/usr/myclientapp/"/>

Debugging Tools


TCPMon allows you to easily view messages as they go back and forth on the wire.


WSMonitor has slightly more functionality than Tcpmon. Information on how to reconfigure clients to work with WSMonitor is available in this blog entry.


SOAP UI can also be used for debugging. In addition to viewing messages, it allows you send messages and load test your services. It also has plugins for Eclipse, IDEA and NetBeans.


Wireshark, a network packet analyzer, can be helpful in case you are getting cryptic WstxUnexpectedCharException errors from CXF's Woodstox StAX processor. This error can indicate a non-XML response from the server (e.g., an HTML error message) that Woodstox can't process. In these cases, Wireshark can help with troubleshooting by providing you the non-XML response data. See this blog entry for more information.

Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences