ColdFusion provides the following facilities for troubleshooting SOAP requests and responses:
- The getSOAPRequest and getSOAPResponse functions.
- The TCP monitor.
Viewing SOAP requests and responses
You can use the getSOAPRequest and getSOAPResponse functions to retrieve and display the XML passed to and from a web service. Although advanced users can use this information for custom functionality, you typically use these functions for debugging.
Use these functions in the following places:
- GetSOAPRequest Clients call this function after the web service request; web service CFCs call this function in the web service CFC method.
- GetSOAPResponse Clients call this function after the web service request completes; web service CFCs cannot use this method.
The following example uses the GetSOAPRequest and GetSOAPResponse functions in a web service client:
<cfscript> |
The following example uses the GetSOAPRequest function in a web service CFC method:
<cfcomponent displayName="testerdebug" hint="Test for underscores"> |
Using the TCP monitor
TCPMonitor is a swing-based application that lets you watch the request and response flow of HTTP traffic. You can also watch the request and response flow of SOAP traffic. TCPMonitor replaces the JRun-based Sniffer tool (sniffer.exe) which existed in ColdFusion 9 and earlier, though it works the same way in its interface.
To run TCPMonitor:
On Windows and UNIX platforms, you can execute the TCPMonitor by using the following command:
java -cp cf_root/cfusion/lib/axis.jar org.apache.axis.utils.tcpmon [listening_port] [target_host] [target_port] |
The TCP Monitor main window appears. Enter the values in the main window as described in the following table:
Field |
Description |
---|---|
Listen Port# |
Enter a local port number, such as 8123, to monitor for incoming connections. Instead of requesting the usual port on which your server runs, you request this port. TCPMonitor intercepts the request and forwards it to the Target Port. |
Listener |
Select Listener to use TCPMonitor as a sniffer service in JRun. |
Proxy |
Select Proxy to enable proxy support for TCPMonitor. |
Target Hostname |
Enter the target host to which incoming connections are forwarded.For example, if you are monitoring a service running on a local server, the hostname is localhost. |
Target Port# |
Enter the port number on the target machine to which TCPMonitor connects. For example, if you are monitoring a service running on your local ColdFusion server in the server configuration, the default port number is 8500. |
HTTP Proxy Support |
Select this check box only to configure proxy support for TCPMonitor. |
To add this profile to your TCPMonitor session, click Add. A tab appears for your new tunneled connection. Select the new tab.
Note that you can also specify the port and host names when launching the tool, as in:java -cp cf_root/cfusion/lib/axis.jar org.apache.axis.utils.tcpmon [listening_port] [target_host] [target_port]
In that case, the tool will use the specified port/host values and open a new tab automatically.
- If port conflicts exist, TCPMonitor alerts you in the Request panel.
Request a page using the Listen Port defined in this TCPMonitor session. For example, if you entered 8123 for the Listen Port, enter the following URL in your browser:
http://localhost:8123/
TCPMonitor displays the current request and response information:For each connection, the request appears in the Request panel and the response appears in the Response panel. TCPMonitor keeps a log of all request-response pairs and lets you view any particular pair by selecting an entry in the top panel.
- To save results to a file for later viewing, click Save. To clear the top panel of older requests that you do not want to save, click Remove Selected and Remove All.
- To resend the request that you are currently viewing and view a new response, click Resend. You can edit the request in the Request panel before resending, and test the effects of different requests.
- To change the ports, click Stop, change the port numbers, and click Start.
- To add another listener, click the Admin tab and enter the values as described previously.
- To end this TCPMonitor session, click Close.