Ask a Jedi: Seeing a SOAP Request that ColdFusion sent

This post is more than 2 years old.

Mike asks:

I have a question regarding calling a SOAP web service and cfscript. I need to add some header information so I'm using the addSOAPRequestHeader Function. Anyhow, my question being is there a way I can debug and somehow see the exact SOAP XML request being sent over the wire?

Yes, you can do this, but it only works when you create an "instance" of the web service. Here is a simple example:

<cfset wurl = "http://localhost/test.cfc?WSDL">

<cfset ws = createObject("webservice", wurl)> <cfset time = ws.time()>

<cfset req = getSoapRequest(ws)> <cfdump var="#req#">

The important bit is the getSoapRequest function. You pass it the web service object, and you get back the XML-based SOAP request that was last used. Dumping it as I did gives you a formatted XML dump, but 'req' as is will give you the pure XML.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Ken Sykora posted on 1/24/2008 at 8:51 PM

It might also be worth mentioning that you can use any sort of decent packet inspection program to piece together a request. My favorite is the windows app Ethereal - it will break out a web service request by by HTTP **and** SOAP. It's a good way to learn about network stacks, as well.

Comment 2 by Mike posted on 1/24/2008 at 10:55 PM

Thanks for both answers.. Initially I had installed wireshark but was having problems with the filters. I'll check out Ethereal.

Comment 3 by Tero Pikala posted on 1/25/2008 at 4:12 AM

Axis TCP monitor is quite ok as well, check URL

http://ws.apache.org/axis/j...

Since CF uses Axis it's actually installed with CF...

Comment 4 by MrBuzzy posted on 1/25/2008 at 2:23 PM

SoapUI (free) is the ducks nuts... http://soapui.org/ although I only use the basics, not sure if it 'sniffs' your requests. It probably does.

Comment 5 by Raymond Camden posted on 1/25/2008 at 5:08 PM

Duck's nutts? That's a new one on me. :)

Comment 6 by Casey posted on 2/13/2008 at 3:32 AM

Another way to see SOAP Requests and Responses is to edit client-config.wsdd in /coldfusion/wwwroot/WEB-INF/ and remove the comments around the <requestFlow> and <responseFlow> lines, then restart Coldfusion, and the request/response should show up in /coldfusion/runtime/logs/coldfusion-out.log

(Tested in ColdFusion 8)

Comment 7 by Nick Battell posted on 4/1/2009 at 1:30 AM

Here is an interesting article about advanced tools for soap monitoring - http://www.correlsense.com/...

Comment 8 by Henry Ho posted on 11/4/2014 at 6:00 AM

Does anyone know how to log SOAP requests in ColdFusion (from which IP and which method?) http://stackoverflow.com/qu...

Thanks!

Comment 9 by Raymond Camden posted on 11/4/2014 at 7:29 AM

I answered.