论坛首页 Java企业应用论坛

使用SOAPMonitor

浏览 3117 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-01-03   最后修改:2009-03-04

    能够监视SOAP消息对于Web Service开发者来说很重要,Axis2自带了这个功能,但是出于安全考虑,Axis2默认状态下并没有启用这个功能。想要启用它,需要下列步骤:

    1、找到axis2.xml文件。它位于<CATALINA_HOME>/webapps/axis2/WEB-INF/conf目录下,添加下面一句话:

 

<module ref="soapmonitor"/>

    2、axis2中定义自己的‘soapmonitorPhase’

 

   <phaseOrder type="inflow">
        <!--System pre defined phases-->
        <phase name="TransportIn"/>
        <phase name="PreDispatch"/>
        <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
            <handler name="AddressingBasedDispatcher"
                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="RequestURIBasedDispatcher"
                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="SOAPActionBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="SOAPMessageBodyBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher">
                <order phase="Dispatch"/>
            </handler>
            <handler name="InstanceDispatcher"
                     class="org.apache.axis2.engine.InstanceDispatcher">
                <order phase="PostDispatch"/>
            </handler>
        </phase>
        <!--System pre defined phases-->
        <!--After Postdispatch phase module author or or service author can add any phase he want-->
        <phase name="userphase1"/>
        <phase name="soapmonitorPhase"/>
    </phaseOrder>
    <phaseOrder type="outflow">
        <!--user can add his own phases to this area-->
        <phase name="userphase1"/>
        <phase name="soapmonitorPhase"/>
        <!--system predefined phase-->
        <!--these phase will run irrespective of the service-->
        <phase name="PolicyDetermination"/>
        <phase name="MessageOut"/>
    </phaseOrder>
    <phaseOrder type="INfaultflow">
        <!--user can add his own phases to this area-->
        <phase name="userphase1"/>
        <phase name="soapmonitorPhase"/>
    </phaseOrder>
    <phaseOrder type="Outfaultflow">
        <!--user can add his own phases to this area-->
        <phase name="userphase1"/>
        <phase name="soapmonitorPhase"/>
        <phase name="PolicyDetermination"/>
        <phase name="MessageOut"/>
    </phaseOrder>

 

   3、在web.xml中加入

 

    <servlet>
       <servlet-name>SOAPMonitorService</servlet-name>
       <display-name>SOAPMonitorService</display-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>

 

   4、<CATALINA_HOME>/webapps/axis2/WEB-INF/lib下有个jar文件叫做soapmonitor-1.4.1.jar,把它解压到axis2根目录<CATALINA_HOME>/webapps/axis2。

   5、浏览器的地址是:http://localhost:8080/axis2/SOAPMonitor

   6、在这里,我们需要注意一个配置问题,如果tomcat下有多个axis应用,设置了多个SOAPmonitor,我们则需要更改SOAPmonitor的端口(axis默认配置的是5001),否则会产生冲突,运行SOAPmonitor时会无法启动,提示the soap monitor is unable to communcate with the server,解决方法如下:

打开C:\Tomcat5\webapps\axis\WEB-INF目录下的web.xml,找到

<servlet>
      <servlet-name>SOAPMonitorService</servlet-name>
      <display-name>SOAPMonitorService</display-name>
      <servlet-class>
          org.apache.axis.monitor.SOAPMonitorService
      </servlet-class>
      <init-param>
        <param-name>SOAPMonitorPort</param-name>
        <param-value>5001</param-value>
      </init-param>
      <load-on-startup>100</load-on-startup>
</servlet>

 这段,将其中的5001改成5002,依此类推。

   7、官方帮助:http://ws.apache.org/axis2/1_3/soapmonitor-module.html

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics