文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>How to use Apache TCP to debug SOAP apps

How to use Apache TCP to debug SOAP apps

时间:2006-03-24  来源:xianglinyan

from: http://www.builderau.com.au/architect/webservices/soa/How_to_use_Apache_TCP_to_debug_SOAP_apps/0,39024590,20271670,00.htm Apache has distributed the TCP Tunnel/Monitor application as part of Apache SOAP. Learn how to use this message monitoring app to debug Web services.

One of the most common tasks during application development is debugging. With new tools and new technologies, debugging is essential to understanding what’s happening and why your application is behaving like expected. To this end, the Apache Group distributes a nice little application as part of Apache SOAP, the TCP Tunnel/Monitor that you can use to monitor and debug your SOAP interfaces. Note that this application only applies to SOAP implementations that use HTTP as the transport.

TCP Tunnel/Monitor
The TCP Tunnel/Monitor application is really just a simple proxy application that includes a visual interface. When you run the application, you specify a host port and a target address and port. TCP Tunnel/Monitor will display a window with two text areas:

  • The text area on the left shows the incoming request, received by the application on the host port you specify.
  • The text area on the right shows the response received from the target server.

You can use the application to monitor servers locally and remotely. If your Web server is local, then you will specify a host port other than the one your Web server is currently using. For example, if you are running Tomcat on port 8080, then you can start the application with the following command:
 
java org.apache.soap.util.net.TcpTunnelGui 8081 localhost 8080
 

This command runs the TcpTunnelGui class and passes in three parameters:

  • The first parameter specifies the port that the tool will listen on. Your SOAP client will have to be redirected to this port rather than the normal port in order to see things happen.
  • The second parameter is the target address (the local machine in this case).
  • The final parameter is the target port (in this case, where Tomcat is listening).

You can point the monitor at remote servers too. Simply change the target address and port to match the host you want to monitor. For example, to monitor the messages to and from the Google Web service, you can use the following command:
 
java org.apache.soap.util.net.TcpTunnelGui 88 api.google.com 80
 

In this case, your client’s SOAP location is now http://localhost:88/search/beta2 instead of http://api.google.com/search/beta2.

SOAP
When you run your SOAP client, it will send a request to the SOAP location you’ve specified. To use this tool, the SOAP location will be different than the normal location. Each request is proxied by the monitor program, so you will have to change the SOAP location of the service you are calling to be at host localhost and at the port you specified as the host port when starting up the tunnel.

For example, if you have an existing Web service client, it may contain some code similar to this:
 
String soaplocation = “http://mywebservice.mydomain.com/soap/servlet/rpcrouter”;
URL soapurl = new URL(soaplocation);
 

You can easily modify this to point to the proxy:
 
String soaplocation = “http://localhost:88/soap/servlet/rpcrouter”;
URL soapurl = new URL(soaplocation);
 

In a real application, the URL is probably not hard-coded in the source but in some externally editable file. In this case, it may make sense to have two parameters in this file—one that points directly to the service and another that points at the proxy address. Then you could add another file item that indicates if the service is in debug mode and use it to dynamically change where the service client points to, like this Java code snippet:
 
String debugmode = myConfiguration.getProperty(“debugMode”);
String soaplocation;
if (debugmode.equalsIgnoreCase(“YES”)) {
   soaplocation = myConfiguration.getProperty(“soapLocation”);
} else {
   soaplocation = myConfiguration.getProperty(“soapLocationDebug”);
}

Not just for debugging SOAP
This tool is useful beyond just monitoring SOAP messages. It can be used to monitor any HTTP service as well—and it’s not dependent on Apache Web servers, either. Because the tool is a generic proxy, you can use it to monitor HTTP and SOAP messages to Microsoft IIS servers, Apache Web servers, Tomcat, WebLogic, or any other HTTP server.

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载