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
A solution to log the Axis Faults is extend the OnFault method :
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
public class SOAPLogHandler extends BasicHandler {
private static final String AXIS = "AXIS";
private static final String AXIS_FAULT = "AXIS FAULT";
private static Logger LOG = LoggerFactory.getLogger(SOAPLogHandler.class);
private static final long serialVersionUID = 1;
@Override
public void invoke(MessageContext msgContext) throws AxisFault {
logMessage(AXIS, msgContext);
}
@Override
public void onFault(MessageContext msgContext) {
try {
logMessage(AXIS_FAULT,msgContext);
} catch (AxisFault axisFault) {
LOG.error("Error on logging messages ",axisFault);
}
}
private void logMessage(String preamble, MessageContext msgContext) throws AxisFault {
if (msgContext.getResponseMessage() != null && msgContext.getResponseMessage().getSOAPPart() != null) {
LOG.info("{} Response ={}",preamble ,msgContext.getResponseMessage().getSOAPPartAsString());
return;
}
if (msgContext.getRequestMessage() != null && msgContext.getRequestMessage().getSOAPPartAsString() != null) {
LOG.info("{} Request={}",preamble,msgContext.getRequestMessage().getSOAPPartAsString());
}
}
}
It is also mandatory to set the handler in the global configuration request flow, in the wsdd file will be something like this :