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 as it is.
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/MonitorThe 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.
- 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).
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.
Enterpise newsletter. Find out what's where in the new Tech Update with our
Guided Tour. Tell us what you think in the
Enterprise Mailroom.





