Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
<!--- general case --->
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks I used some working code I had on another page and rebuild around this app.
I always need to have these resources next to me because I forget how to build the code
this works for me
<cfhttp url="<api url>" method="GET" resolveurl="No" ></cfhttp>
<cfset mydoc = XmlParse(CFHTTP.FileContent)>
<cfset pb = mydoc.variable1.XmlChildren>
<cfset size = ArrayLen(pb)>
<cfset myquery = QueryNew("variable1,variable2, variable3")>
<cfset temp = QueryAddRow(myquery, #size#)>
<cfset temp = QuerySetCell(myquery, "variable3", #mydoc.variable3.XmlText#)>
<cfif #mydoc.variable1.variable2.variable3.XmlText# eq "Success">
Action
</cfif>
Copy link to clipboard
Copied
this works for me
<cfhttp url="<api url>" method="GET" resolveurl="No" ></cfhttp>
<cfset mydoc = XmlParse(CFHTTP.FileContent)>
<cfset pb = mydoc.variable1.XmlChildren>
<cfset size = ArrayLen(pb)>
<cfset myquery = QueryNew("variable1,variable2, variable3")>
<cfset temp = QueryAddRow(myquery, #size#)>
<cfset temp = QuerySetCell(myquery, "variable3", #mydoc.variable3.XmlText#)><cfif #mydoc.variable1.variable2.variable3.XmlText# eq "Success">
Action
</cfif>
You apparently didn't take the hint, Ian's or mine. What you've done may be correct, it unnecessarily involves too many functions. You could really do it more efficiently, like this
<cfxml variable="xmlString"><cfoutput>#cfhttp.FileContent#</cfoutput></cfxml>
<cfset statusArray=xmlSearch(xmlString,"//VerificationStatus")>
<cfif statusArray[1].xmlText eq "Success">
Action
</cfif>