I am using cfhttp to call a service call where I am setting the cfhttpparam type = 'url' name $format value = 'xml' to get a response in xml. I have dumped my variable and everything in the filecontent shows that the format is in xml I think since it says and lists all the variables I was calling for. So I assumed using XMLParse for the results would allow me to obtain the data from the results and define them to variables I can use on the web.
<cfset request.getResponse = structNew() />
<cfhttp
method="get"
url="http://testsite"
result="request.getResponse " username="xxxxxx" password="test">
<cfhttpparam type="url" name="$expand" value="GetRoles,GetVendors" />
<cfhttpparam type="url" name="$format" value="xml" />
</cfhttp>
<cfdump var="#request.getResponse #">
<cfset FullResponse = XMLParse(request.getResponse )>
<cf_upXMLToStruct XML="#FullResponse#" SoftError="false" variable = "structResponse">
<cfset rspFirstName = UCASE(trim(structResponse.XML_STRUCT.FirstName)) />
<cfset rspShoteName = trim(structResponse.XML_STRUCT.ShortName) />
<cfset rspCompanyName = trim(structResponse.XML_STRUCT.CompanyName) />
But I am getting an error:
Complex Object types cannot be converted to simple values.
I am still new to XML, so I am not sure what I need to do to evaluate the XML. Here is a snip of the response I receive:
<entry>
<id>http:// TEST/VendorDetailsSet('1000000240')</id>
<title type="text">VendorDetailsSet('1000000240')</title>
<updated>2017-05-18T15:24:44Z</updated>
<category term=" TEST.VendorDetails"
scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="VendorDetailsSet('1000000240')" rel="self"
title="VendorDetails"/>
<content type="application/xml">
<m:properties>
<d:Address m:type=" TEST.AddressDetails">
<d:HouseNumber/>
<d:Street1/>
<d:Street2/>
<d:City/>
<d:Region/>
<d:PostalCode/>
<d:Country/>
<d:HomePhone/>
<d:MobileNumber/>
<d:FaxNumber/>
<d:CompanyEmail/>
</d:Address>
<d:VendorNumber>1000000240</d:VendorNumber>
<d:VendorName>ABC COMPANY</d:VendorName>
</m:properties>
</content>
</entry>
Do I need to do something to the results before I can XMLParse it or is there another XML tag I can use to evaluate the results?
I am still learning XML in the ColdFusion environment so any assistance or advice to help me learn on how I can grab the data from the XML would be great.
I do also have the option to return the results in JSON format if that makes it easier.
<cf_upXMLToStruct...>
. – Leigh<cfdump var="#request.getResponse #">
– Leigh