How to debug Web Services

In this tutorial we will see how you can debug your JBoss Web Services applications by using some built-in logging features or using an external TCP dumper.

Using a System Property to Debug SOAP Messages

Debugging SOAP Messages is a critical activity for every application running Web Services.The simplest way to see the full SOAP messages returned by JBoss or WildFly is to add this System Property to your server which will print the incoming and outgoing SOAP XML Messages:
        <property name="org.apache.cxf.logging.enabled" value="true"/>

Important: in the current version of WildFly there is an issue related with this System Property. Check this JIRA to see if it’s solved:

Adding Logging Feature

Features in CXF works like decorators. It can be applied to server and client bus components. In a nutshell it  extends the functionality of the server, client or the bus. CXF provides some of the built-in Feature implementations and one of them is LoggingFeature feature class. The LoggingFeature class performs logging of SOAP messages. You can simply add the LoggingFeature to your endpoint as follows:


Please note that you can add Features using JaxWsServerFactoryBean as shown in the following code:

HelloWorldImpl implementor = new HelloWorldImpl(); 
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); 
svrFactory.getFeatures().add(new LoggingFeature());

Using a Proxy to capture SOAP Messages

Another option is to use a proxy which prints the incoming and outgoing SOAP Messages. There are plenty of options available like netcat, For example, here is how to set up a proxy on port 8082 which forwards tcp messages on port 8080, printing them:

ncat -lkv localhost 8082 -c 'tee /dev/stderr | ncat -v localhost 8080 | tee /dev/stderr'

If you prefer using a graphical tool for setting up a proxy, then you can use Apache TCPMon which is a valuable tool for monitoring your network applications.

Download here the lastest stable release of it.

Configuring the Monitor is pretty easy. For our purpose we need to intercept Web Service request before they reach the Server and as well we need to capture response before they reach the client.

In the Admin tab select a Listening port for Apache TCPMon and a target port which corresponds to JBoss AS listening port. For example:

jboss web services debug tcpmon 
Now modify your Web Services client so that they point to the Apache TCPMon Port instead of JBoss. For example:

 public static void main(String args[]) throws Exception {   
 String endpointURI ="";   
 String helloWorld = "Hello world!";   
 Object retObj = getPort(endpointURI).echo(helloWorld);   
In the meantime, you will find the outcomign and incoming SOAP Messages in the TCPMon Console:
TCPMon is a simple and easy to use tool that has many benefits when developing message driven applications. It is particularly useful in developing Web services.
For additional information about it, check: