Wednesday, July 15, 2009

Logging SOAP messages AXIS client

If you want to debug your axis web service client and do not want to alter any code, you can follow this procedure to log all incoming and outgoing soap messages.

make a file with the name client-config.wsdd with this content:

<!--
Save this file as "client-config.wsdd" in the working directory
of your Axis client. Axis will load it automatically. The
configuration here tells Axis to save all incoming and outgoing
XML into a file named "axis.log"
-->

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<handler name="log" type="java:org.apache.axis.handlers.LogHandler" >
<parameter name="LogHandler.fileName" value="c:/logs/soapmessages.log"/>
</handler>

<globalConfiguration>
<requestFlow>
<handler type="log" />
</requestFlow>
<responseFlow>
<handler type="log" />
</responseFlow>
</globalConfiguration>

<transport name="http"
pivot="java:org.apache.axis.transport.http.HTTPSender" />

</deployment>

Dump it in the class root of the application, so the axis loader can pick it up (where you would place log4j.properties for example).

The only downfall is that you cannot dynamically change your logging level. You'll have to remove the file to disable the tracing.