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:
<system-properties>
        <property name="org.apache.cxf.logging.enabled" value="true"/>
</system-properties>  

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: https://issues.jboss.org/browse/JBWS-4120

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:

@org.apache.cxf.feature.Features(features={"org.apache.cxf.feature.LoggingFeature"})
Please note that you can add Features using JaxWsServerFactoryBean as shown in the following code:
HelloWorldImpl implementor = new HelloWorldImpl(); 
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); 
svrFactory.setServiceClass(HelloWorld.class); 
svrFactory.setAddress("http://localhost:9000/helloWorld"); 
svrFactory.setServiceBean(implementor); 
svrFactory.getFeatures().add(new LoggingFeature());
svrFactory.create();

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 ="http://127.0.0.1:8888/ejb/HelloWorld?wsdl";   
 String helloWorld = "Hello world!";   
 
 Object retObj = getPort(endpointURI).echo(helloWorld);   
 System.out.println(retObj);   
 }   
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:
https://ws.apache.org/tcpmon/tcpmontutorial.html
0
0
0
s2smodern

Related articles available on mastertheboss.com

JBoss web services

JAX-WS simplifies the development model for a web service endpoin

What is a Web Service One Way invocation?

JBoss recipe of the day

Asynchronous web services with JBoss WS

Developing rigorous and responsive web service client application

How to change the default Web Service deployment Port ?

JBoss recipe of the day

Using Axis Web Services with JBoss

Still not ready for JBoss WS ? if you don't have a JDK 1.5 compli

Invoking JBoss Web Services with Flex

Flex® is a free, open source framework for building highly in

W

i

l

d

F

l

y

 

c

h

e

a

t

s

h

e

e

t