Ask a Jedi: Seeing a SOAP Request that ColdFusion sent

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#”> </code>

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 developer advocate. He focuses on JavaScript, serverless 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

Comments