记录axis2客户端请求和响应
我想记录axis2客户端发出的所有请求/响应。 我试图在http://code.google.com/support/bin/answer.py?hl=zh-CN&answer=15137中创建一个名为client-config.wsdd
的文件作为描述,但没有成功(我没有得到日志文件)。
请求是通过https进行的,我不确定是否重要。 我试过了
和
没有成功。
对于SOAP消息的Axis2客户端记录,只需在运行独立客户端时使用以下JVM参数,或在Appln中包含此VM args。 服务器启动脚本,
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
干杯,桑卡尔
我知道它有点冗长,但这是我们如何解决它:
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); OMElement requestElement = request.getOMElement(RegisterIntegrationAgent.MY_QNAME, factory); LOGGER.debug(requestElement);
如果将以下行添加到log4j.properties文件中,则无需传递任何VM或JVM参数。
log4j.logger.httpclient.wire.content = DEBUG,Axis3LogFile
#Axis2 log4j.appender.Axis2LogFile=org.apache.log4j.RollingFileAppender log4j.appender.Axis2LogFile.File=${catalina.base}/logs/Axis2-client.log log4j.appender.Axis3LogFile.layout=org.apache.log4j.PatternLayout log4j.appender.Axis3LogFile.layout.ConversionPattern=%d{ISO8601} [%X{UUID}] %5p %t %c{1} - %m%n
我通常只记录SOAP消息的主体,传递给我的服务类。
public OMElement myOperation(OMElement request) throws AxisFault { log.debug("Request: {}", request); .. log.debug("Response: {}", response); return response }
低技术但对我有用:-)
-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
这很有效