简体   繁体   中英

Logging the raw XML of a SOAP request/response using JAX-RPC

I'm using JAX-RPC and wanted to know if there is a way to make JAX-RPC print the raw SOAP Request/Response for debug purposes.

I saw that JAX-RPC uses log4j but did not see which logger I should turn on with DEBUG to view the message before it is sent.

If you are using Apache Axis, here is the log4J configuration you can use:

<appender name="wsAppender" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="${catalina.base}/logs/MY_APP-ws.log" />
    <param name="Append" value="true" />
    <param name="MaxFileSize" value="20MB" />
    <param name="MaxBackupIndex" value="10" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %m%n" />
    </layout>
      <filter class="org.apache.log4j.varia.StringMatchFilter">
              <param name="StringToMatch" value="MY_SPECIFIC_WSProcessRequest" />
              <param name="AcceptOnMatch" value="true" />
      </filter>
    <filter class="org.apache.log4j.varia.DenyAllFilter"/>
</appender>

<logger name="org.apache.axis.transport.http.HTTPSender" additivity="false">
    <level value="DEBUG" />
    <appender-ref ref="wsAppender"/>
</logger>

Change MY_SPECIFIC_WSProcessRequest for the specific value matching the XML request you want to log.

我建议您实现一个Handler ,该Handler将具有handleRequesthandleResponse方法( doc ),可以重写该方法来操纵您的请求/响应(有关如何使用处理程序的文档 )。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM