隨筆 - 312, 文章 - 14, 評論 - 1393, 引用 - 0
          數據加載中……

          WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息

          本文為原創,如需轉載,請注明作者和出處,謝謝!

          上一篇:WebService大講堂之Axis2(9):編寫Axis2模塊(Module)

              Axis2中提供了一個Axis2模塊(soapmonitor),該模塊實現了與《WebService大講堂之Axis2(9):編寫Axis2模塊(Module)》中實現的logging模塊相同的功能,所不同的是,logging模塊直接將SOAP請求與響應消息輸出到Tomcat控制臺中,而soapmonitor模塊利用applet直接在頁面中輸出SOAP請求和響應消息。

              下面是配置和使用soapmonitor模塊的步驟:   

          1步:部署AppletServlet

              由于axis2默認情況下已經自帶了soapmonitor模塊,因此,soapmonitor模塊并不需要單獨安裝。但applet所涉及到的相應的.class文件需要安裝一下。在<Tomcat安裝目錄>\webapps\axis2\WEB-INF\lib目錄中找到soapmonitor-1.4.1.jar文件,將該文件解壓。雖然applet并不需要soapmonitor-1.4.1.jar文件中所有的.class文件,但為了方便,讀者也可以直接將解壓目錄中的org目錄復制到<Tomcat安裝目錄>\webapps\axis2目錄中,Applet所需的.class文件需要放在這個目錄。然后再將org目錄復制到<Tomcat安裝目錄>\webapps\axis2\WEB-INF\classes目錄中,soapmonitor模塊中的Servlet所對應的.class文件需要放在這個目錄。

          2步:配置Servlet

              打開<Tomcat安裝目錄>\webapps\axis2\WEB-INF\web.xml文件,在其中加入如下的內容:

          <servlet>
              
          <servlet-name>SOAPMonitorService</servlet-name>
              
          <servlet-class>
                  org.apache.axis2.soapmonitor.servlet.SOAPMonitorService
              
          </servlet-class>
              
          <init-param>
                  
          <param-name>SOAPMonitorPort</param-name>
                  
          <param-value>5001</param-value>
              
          </init-param>
              
          <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet-mapping>
              
          <servlet-name>SOAPMonitorService</servlet-name>
              
          <url-pattern>/SOAPMonitor</url-pattern>
          </servlet-mapping>

          3步:在services.xml文件中引用soapmonitor模塊

              與引用logging模塊一樣,引用soapmonitor模塊也需要使用<module>元素,引用soapmonitor模塊的services.xml文件的內容如下:
          <service name="myService">
              
          <description>
                  使用logging和soapmonitor模塊
              
          </description>
              
          <!--  引用logging模塊  -->
              
          <module ref="logging"/>
              
          <!--  引用soapmonitor模塊  -->
              
          <module ref="soapmonitor"/>
              
          <parameter name="ServiceClass">
                  service.MyService   
              
          </parameter>
              
          <messageReceivers>
                  
          <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                      class
          ="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
              
          </messageReceivers>
          </service>

              由于soapmonitor模塊已經在axis2.xml進行配置了,因此,在本例中不需要再對axis2.xml文件進行配置了。   

          4步:使用soapmonitor模塊

              啟動Tomcat后,在瀏覽器中輸入如下的URL:

          http://localhost:8080/axis2/SOAPMonitor

              在瀏覽器中將出現soapmonitor所帶的Applet的界面,當訪問MyServicegetGreeting方法時,在Tomcat控制臺與Applet中都顯示了相應的SOAP請求和響應消息。如圖1和圖2分別是調用了兩次getGreeting方法后輸出的SOAP請求和響應消息。



          圖1



          圖2

              如果讀者想讓loggingsoapmonitor模塊監視部署在Axis2中的所有WebService,可以在axis2.xml文件中使用<module>元素來引用這兩個模塊,代碼如下:

              <!--  引用logging模塊  -->
              
          <module ref="logging"/>
              
          <!--  引用soapmonitor模塊  -->
              
          <module ref="soapmonitor"/>




          Android開發完全講義(第2版)(本書版權已輸出到臺灣)

          http://product.dangdang.com/product.aspx?product_id=22741502



          Android高薪之路:Android程序員面試寶典 http://book.360buy.com/10970314.html


          新浪微博:http://t.sina.com.cn/androidguy   昵稱:李寧_Lining

          posted on 2009-02-17 09:22 銀河使者 閱讀(9223) 評論(8)  編輯  收藏 所屬分類: java 原創webservice

          評論

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          除了用模塊還有沒有其他方法可以獲取SOAP頭的?謝謝
          2009-05-18 12:03 | 我有問題

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          SOAP消息是底層的信息,除非提供了接口,否則無法獲得這些信息。我一般是通過模塊獲得soap消息,但通過其他方式還沒試過。
          2009-05-18 12:49 | 銀河使者

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          大哥,你的QQ群滿人了阿,加不進去阿,加我阿,我qq451684548
          2009-07-14 09:52 | 大佬

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          我有按照你上面的配置,啟動能成功。但是訪問服務http://localhost:8080/axis2/SOAPMonitor的時候老是不能彈出什么東西
          就光禿禿的一個頁面,什么都沒有顯示,服務器也沒有報錯!
          這個是什么原因啊?沒實現你上面說的那個applet界面呀!!
          2009-10-24 21:14 | zuowangxi

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          @zuowangxi
          有可能是你的瀏覽器阻止了applet的顯示,試試修改一下瀏覽器的安全隔離級別
          2010-01-21 17:25 | Mr.Blue

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          后面的章節怎么沒有了?
          2010-06-03 18:09 | web

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息  回復  更多評論   

          在WEB-INFO/lib里面已經有了soapmonitor的jar,還有必要把解壓出來的東西放到classes下面嗎?
          2010-09-10 21:21 | A.L

          # re: WebService大講堂之Axis2(10):使用soapmonitor模塊監視soap請求與響應消息[未登錄]  回復  更多評論   

          好東西,這十講是過了一遍了,就是不知道怎么用到實際項目開發中去~~~
          2011-08-04 10:03 | frank
          主站蜘蛛池模板: 手机| 沽源县| 会东县| 云和县| 平南县| 云浮市| 衢州市| 区。| 安溪县| 大荔县| 济阳县| 开阳县| 灵台县| 阳高县| 泗洪县| 巨野县| 莱芜市| 利川市| 揭西县| 普宁市| 上高县| 龙江县| 孝义市| 吴堡县| 麻栗坡县| 黄梅县| 方山县| 岑巩县| 三门峡市| 勃利县| 永宁县| 张家港市| 阿克陶县| 沅陵县| 新泰市| 禄丰县| 桃园市| 广丰县| 武隆县| 巨鹿县| 长岛县|