Search code examples
asp.netsoapcoldfusioncoldfusion-8

Coldfusion SOAP request preview


I need to consume a asp.net web service using ColdFusion 8 and return an XML file.

I am able to communicate with asp.net service but am returned an error from the service that basically says the information I passed was not valid.

Here is a run down of my code :

<cfxml variable="soap">
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"   
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <soap:Body>
<cfoutput> <GetSession xmlns="#stagingurl#"></cfoutput>  
  <strApplicationKey>myappkey</strApplicationKey>
  <UID>myuserid</UID>
  <arrProperties>
    <Property>
      <Name>IP</Name>
      <Value>127.0.0.1</Value>
    </Property>
  </arrProperties>
  <arrRoles />
</GetSession>
</soap:Body>
</soap:Envelope>         
</cfxml>

<cfhttp url="#apiurl#" method="post" result="httpresponse" port="443">

  <cfhttpparam type="header" name="content-type" value="text/xml"> 
  <cfhttpparam type="header" name="SOAPAction" value="#mysoapaction#"> 
  <cfhttpparam type="header" name="content-length" value="#len(trim(soap))#"> 
  <cfhttpparam type="header" name="charset" value="utf-8">
  <cfhttpparam type="Body" value="#trim(soap)#" name="FileContent"/>  

</cfhttp>

<cfdump var="#GetHttpRequestData()#" label="Get Http Request Data" />

Is there a way to preview the information being sent to make sure that ColdFusion is actually sending my XML/SOAP request?

I did use #GetHttpRequestData()# to return some data and within the structure, content is "empty string" and this is where I need help. Should this be empty? This is new for me, but, I guess I expected that my information being passed to the asp.net service would be in there.

FYI - I can see the HTTP and SOAP response fine, I just can not see the request information. How do I view the Request information?

Still trying to determine if the issue is on my end, or theirs and need to gather facts at this point.


Solution

  • Another invaluable tool when working with web services is soapUI. That should definitely be a part of your toolkit as well. You can build your request using soapUI and check the responses. Once you have it working with soapUI you can copy your request into your ColdFusion code.

    One thing that I noticed is that your are wrapping your XML in a cfxml tag. I'm not sure if that is messing with your request or not. I typically wrap my XML request in cfsavecontent tags. So you could try changing your code like this:

    <cfsavecontent variable="soap">
    <?xml version="1.0" encoding="UTF-8" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <soap:Body>
       <cfoutput> <GetSession xmlns="#stagingurl#"></cfoutput>  
       <strApplicationKey>myappkey</strApplicationKey>
       <UID>myuserid</UID>
       <arrProperties>
         <Property>
           <Name>IP</Name>
           <Value>127.0.0.1</Value>
         </Property>
       </arrProperties>
       <arrRoles />
       </GetSession>
       </soap:Body>
    </soap:Envelope>         
    </cfsavecontent>
    

    The rest of your code can remain the same.