参照Axis2-1.0的bin版本下提供的文档soapmonitor-module.html http://ws.apache.org/axis2/1_1/soapmonitor-module.html 来使用SOAPMonitor来监测SOAP消息发送时的发送消息和接收的消息。
要使用SOAPMonitor,前提是浏览器要安装Java plug-in1.3以上的版本,如果没有安装需要另外安装,并可以在浏览器中进行设置,在控制面板->java 中设置 “网络配置”,采用“使用浏览器”,如果SOAPMonitor能够正常使用,可以通过浏览器观察
http://localhost:8080/axis2/SOAPMonitor
8080 是应用服务所使用的端口。 soapmonitor-1.0.mar文件本身就存在于module目录下,只是axis2默认时出于安全考虑没有使用。如果要使用SOAPMonitor模块,需要改变的内容有:
1、编辑axis2.xml文件,在模块注释一下添加模块的引用
<module ref="soapmonitor"/>
2、添加自定义的phase
在axis2.xml文件中,在"inflow","outflow","INfaultflow","OutFaultFlow"部分有标志user can add his own phases to this area' 注册之后添加soapmonitorPhase 来定义soapmonitorPhase引用soapmonitor.mar文件中的module.xml文件。axis2.xml文件中添加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.engine.AddressingBasedDispatcher">
<order phase="Dispatch"/>
</handler>
<handler name="RequestURIBasedDispatcher"
class="org.apache.axis2.engine.RequestURIBasedDispatcher">
<order phase="Dispatch"/>
</handler>
<handler name="SOAPActionBasedDispatcher"
class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
<order phase="Dispatch"/>
</handler>
<handler name="SOAPMessageBodyBasedDispatcher"
class="org.apache.axis2.engine.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能和applet进行交互,需要修改web.xml文件,在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 、编译SOAPMonitorApplet.java文件
此文件可以从发source文件中获得,编译口令为:
javac -classpath axis2-soapmonitor-1.0.jar SOAPMonitorApplet.java
将编译生成的文件复制到axis2的根目录下,也可以直接从axis2.war下的WEB-INF\lib目录下对axis2-soapmonitor-1.0.jar文件执行jar命令获得SOAPMonitorApplet*.class文件,执行命令为: WEB-INF\lib>jar -xf axis2-soapmonitor-1.0.jar ,将获得的文件及目录复制到webapps\axis2目录下即可。
5、执行验证
址栏中输入http://localhost:8080/axis2/SOAPMonitor 可以看到启动后界面如下