Look up information on creating a logging handler which will output such information 
to whatever source you wish to define. Here is a sample logging handler:

import javax.xml.namespace.QName;
import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;

import org.apache.log4j.Logger;

public class LoggingHandler implements Handler {
    Logger log;

    public void destroy() {
    }

    public QName[] getHeaders() {
        return null;
    }
    
    public boolean handleFault(MessageContext mc) {
        log.error("requestor fault");
        log.error(getEnvelope(mc));
        return true;
    }

    public boolean handleRequest(MessageContext mc) {
        log.info("requestor request");
        log.info(getEnvelope(mc));
        return true;
    }

    public boolean handleResponse(MessageContext mc) {
        log.info("requestor response");
        log.info(getEnvelope(mc));
        return true;
    }

    public void init(HandlerInfo hi) {
        log = Logger.getLogger(this.getClass());
    }

    private String getEnvelope(MessageContext mc) {
        SOAPMessageContext smc = (SOAPMessageContext) mc;
        SOAPMessage msg = smc.getMessage();
        String value = "";
        try {
            value = msg.getSOAPPart().getEnvelope().toString();
        } catch (SOAPException se) {
            se.printStackTrace();
        }
        return value;
    }
}

In a message dated 7/19/2004 5:24:04 PM Eastern Daylight Time, "Deppen, Jeff" <[EMAIL 
PROTECTED]> writes:

>All,
>
>I need to capture statistics/info for each of my methods.  In addition to
>capturing start and stop times, I also need the xml request/response.  Axis
>is great at parsing and converting the soap message to/from java, however,
>by the time I (my java code) get's control, the soap message is long gone.
>How can I get to it?  (I suppose I could do something with log4j that
>filters out everything except for the request/response soap messages but I'm
>concerned this would introduce some serious performance issues.)
>
>Any help/thoughts would be appreciated.
>
>thanks
>jeff
>

Reply via email to