I am having the next problem:
I want to log the SOAP requests/responses that land on my web service (server side). Trying to configure my web service in the wsdd fil
So after hours or Googling out there in the web, I decided to get adventurous and program my own handler. Is much easier than expected.
I made a class that extends the abstract class BasicHandler (org.apache.axis.handlers.BasicHandler), and implements the invoke method loging the request or the response. Here is my class, which I have baptized as SOAPLogHandler :
package com.mypackage.axishandlers;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.log4j.Logger;
public class SOAPLogHandler extends BasicHandler {
private static Logger LOG= Logger.getLogger(SOAPLogHandler.class);
private static final long serialVersionUID = 1L;
@Override
public void invoke(MessageContext msgContext) throws AxisFault {
if(msgContext.getResponseMessage() != null && msgContext.getResponseMessage().getSOAPPart() != null) {
LOG.info(" Response = " + msgContext.getResponseMessage().getSOAPPartAsString());
} else {
if(msgContext.getRequestMessage() != null && msgContext.getRequestMessage().getSOAPPartAsString() != null) {
LOG.info(" Request = " + msgContext.getRequestMessage().getSOAPPartAsString());
}
}
} }
The idea is, to log first the request, and when processed, log the response. So, in the server-config.wsdd (or the wsdd file from your client if you are in the client side), we have to add a handler pointing to that class, and configure it to uses in the request/response chain:
1st add the handler
2nd add the use of that handler to the request/response from the http transport (focus on the log handler)
...
With that, the magic should be done, and you should receive a pretty log from the request/responses!
Disclaimer: I am not really sure from what will happend if you use some kind of SOAP multipart thing.