Skip to main content
lovewebdev
Inspiring
January 13, 2010
Question

Submit values and retrieve responses from xml api

  • January 13, 2010
  • 2 replies
  • 777 views

I use this code to submit to an api

<cfhttp url="<api url>" method="GET" resolveurl="No" ></cfhttp>

I get back


<VerifySignatureResponse>
−<VerifySignatureResult>
<VerificationStatus>Success</VerificationStatus>
</VerifySignatureResult>
</VerifySignatureResponse>

How do I retrieve the response? I ned to get back the Success for the VerificationStatus parameter

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
January 13, 2010

<!--- general case --->


<!--- <cfxml variable="xmlString"><cfoutput>#cfhttp.FileContent#</cfoutput></cfxml> --->

<cfxml variable="xmlString">
<VerifySignatureResponse>
<VerifySignatureResult>
<VerificationStatus>Success</VerificationStatus>
</VerifySignatureResult>
</VerifySignatureResponse>
</cfxml>

<cfset statusArray=xmlSearch(xmlString,"//VerificationStatus")>
<cfdump var="#statusArray#">
status: <cfoutput>#statusArray[1].xmlText#</cfoutput>
lovewebdev
Inspiring
January 13, 2010

I don't really understand this cfxml code

In this case you hard coded the word Success.

In the real application the xml is hosted on another server. I send some variables in the URL querystring to the url.

When I enter the url directly in the address bar o the browser I see the xml sheet and the response.

I want to automatically read what was returned through coldfusion

ilssac
Inspiring
January 13, 2010

He was showing you and example of how to parse and view XML data.  Since he did not have access to your web service to get the xml he created an example of it in his code so that he had some xml data to parse and show you.

You can assume everthing in between the <cfxml...> tags is the same as your <cfhttp...> tag.  It creates some xml data to be utilized.

Inspiring
January 13, 2010

If the response is xml, try parsing it with XMLParse(). It returns a "structure-like" object. You can then access the elements with dot/array notation. Cfdump the results of XMLParse() to visualize how to access the element you need.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_t-z_23.html

http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_t-z_23.html