Oct 09, 2010

Apache Axis2 で HTTP Request/Response を確認する方法

Axis2 は通信に Apache HttpComponents を使用しているので Log4j で HTTP Request/Response を確認することができる。 SOAP 通信の内容を見られるのでデバッグの際にとても便利。

log4j.xml の設定方法

"httpclient.wire" カテゴリのログレベルを "debug" にするだけ。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
 
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

  <!-- for Axis2 -->
  <category name="httpclient.wire">
    <priority value="debug" />
  </category>
  <!-- /for Axis2 -->

</log4j:configuration>

ログ出力例

2010-10-08 23:02:45,670 DEBUG [main] (Wire.java:70) - >> "POST /services/Soap/u/20.0 HTTP/1.1[\r][\n]"
2010-10-08 23:02:45,682 DEBUG [main] (Wire.java:70) - >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
2010-10-08 23:02:45,682 DEBUG [main] (Wire.java:70) - >> "SOAPAction: "urn:partner.soap.sforce.com:Soap:loginRequest"[\r][\n]"
2010-10-08 23:02:45,682 DEBUG [main] (Wire.java:70) - >> "User-Agent: Axis2[\r][\n]"
2010-10-08 23:02:45,683 DEBUG [main] (Wire.java:70) - >> "Host: test.salesforce.com[\r][\n]"
2010-10-08 23:02:45,683 DEBUG [main] (Wire.java:70) - >> "Transfer-Encoding: chunked[\r][\n]"
2010-10-08 23:02:45,683 DEBUG [main] (Wire.java:70) - >> "[\r][\n]"
2010-10-08 23:02:46,146 DEBUG [main] (Wire.java:70) - >> "143[\r][\n]"
2010-10-08 23:02:46,146 DEBUG [main] (Wire.java:84) - >> "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>(略)</soapenv:Body></soapenv:Envelope>"
2010-10-08 23:02:46,147 DEBUG [main] (Wire.java:70) - >> "[\r][\n]"
2010-10-08 23:02:46,147 DEBUG [main] (Wire.java:84) - >> "0"
2010-10-08 23:02:46,147 DEBUG [main] (Wire.java:70) - >> "[\r][\n]"
2010-10-08 23:02:46,148 DEBUG [main] (Wire.java:70) - >> "[\r][\n]"
2010-10-08 23:02:46,488 DEBUG [main] (Wire.java:70) - << "HTTP/1.1 200 OK[\r][\n]"
2010-10-08 23:02:46,488 DEBUG [main] (Wire.java:70) - << "HTTP/1.1 200 OK[\r][\n]"
2010-10-08 23:02:46,490 DEBUG [main] (Wire.java:70) - << "Server: [\r][\n]"
2010-10-08 23:02:46,490 DEBUG [main] (Wire.java:70) - << "Content-Type: text/xml; charset=utf-8[\r][\n]"
2010-10-08 23:02:46,491 DEBUG [main] (Wire.java:70) - << "Content-Length: 1626[\r][\n]"
2010-10-08 23:02:46,491 DEBUG [main] (Wire.java:70) - << "Date: Fri, 08 Oct 2010 23:02:46 GMT[\r][\n]"
2010-10-08 23:02:46,491 DEBUG [main] (Wire.java:70) - << "[\r][\n]"
2010-10-08 23:02:46,499 DEBUG [main] (Wire.java:84) - << "<?xm"
2010-10-08 23:02:46,502 DEBUG [main] (Wire.java:84) - << "l version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>(略)</soapenv:Body></soapenv:Envelope>"

TrackBack ping me at
http://www.in-vitro.jp/blog/index.cgi/Library/20101009_01.trackback
Post a comment

writeback message: Ready to post a comment.