Log axis2 client requests and responses
I would like to log all requests/responses made by an axis2 client.
I tried to create a file called client-config.wsdd
as describer 开发者_开发百科in http://code.google.com/support/bin/answer.py?hl=en&answer=15137 but without success (I don't get a log file).
Requests are made over https and I am not sure if it matters. I tried
<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
and
<transport name="https" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
without success.
For Axis2-client side logging for SOAP messages, just use the following JVM arguments while running your standalone client or include this VM args in your Appln. Server start script,
JAVA_OPTS=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.httpclient.wire=debug -Dorg.apache.commons.logging.simplelog.log.org.apache.commons.httpclient=debug
C:\java %JAVA_OPTS% YourClientAppln.java
Cheers, Sankar
If you add the below lines to your log4j.properties file, you will need not to pass any VM or JVM parameters.
#Axis2
log4j.appender.AxisLogFile=org.apache.log4j.RollingFileAppender
log4j.appender.AxisLogFile.File=${catalina.base}/logs/Axis-client.log
log4j.appender.AxisLogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.AxisLogFile.layout.ConversionPattern=%d{ISO8601} [%X{UUID}] %5p %t %c{1} - %m%n
log4j.logger.httpclient.wire=DEBUG,AxisLogFile
I know it's a bit verbose, but here's how we solved it:
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
OMElement requestElement = request.getOMElement(RegisterIntegrationAgent.MY_QNAME, factory);
LOGGER.debug(requestElement);
I normally just log the body of the SOAP message, passed to my service class.
public OMElement myOperation(OMElement request) throws AxisFault {
log.debug("Request: {}", request);
..
log.debug("Response: {}", response);
return response
}
Low tech but works for me :-)
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.showdatetime=true -Dorg.apache.commons.logging.simplelog.log.httpclient.wire=debug -Dorg.apache.commons.logging.simplelog.log.org.apache.commons.httpclient=debug
This worked
精彩评论