webservices with xml file
Hi,
How can I read xml file using web services?
Here is my cfc web services: (I just want to see how to read the xml file)
<cfcomponent>
<cffunction name="getBooks" access="remote" returntype="string" output="no">
<cfargument name="xmlObject" type="xml" required="yes" >
<cfset BookResponse = "">
<cfset var arrIndx = "">
<cftry>
<cfloop from="1" to="#ArrayLen(arguments.xmlObject.XmlChildren)#" index="arrIndx">
<cfset BookResponse= arguments.xmlObject.XmlChildren[arrIndx].XmlName>
</cfloop>
<cfcatch type="any">
<cfset BookResponse= "#cfcatch.message# #cfcatch.detail#">
</cfcatch>
</cftry>
<cfreturn BookResponse>
</cffunction>
</cfcomponent>
Here my code to test the web services:
1. Define the xml
<!--- Setup some XML to work with --->
<cfsavecontent variable="XMLFile"><?xml version="1.0"?>
<root>
<header>
<user>1</user>
</header>
<book>
<isbn>0321330110</isbn>
<title>Macromedia ColdFusion MX 7 Certified Developer Study Guide</title>
<author>Ben Forta</author>
</book>
<header>
<user>2</user>
</header>
<book>
<isbn>0596004206</isbn>
<title>Learning XML, Second Edition</title>
<author>Erik Ray</author>
</book>
<header>
<user>3</user>
</header>
<book>
<isbn>0782140297</isbn>
<title>Coldfusion MX Developer's Handbook</title>
<author>Raymond Camden</author>
</book>
</root>
</cfsavecontent>
2.Invoke the web services
<cfinvoke
method="getBooks"
returnvariable="rawXMLBookList"
webservice="http://localhost/Hoteleria/webServices/books.cfc?wsdl">
<cfinvokeargument name="xmlObject" value="#XMLFile#">
</cfinvoke>
<!---<cfset XMLDocResult = XmlParse(rawXMLBookList)>
<cfdump var="#XMLDocResult#">--->
<cfdump var="#rawXMLBookList#' >
3. Error: Element XMLOBJECT.XMLCHILDREN is undefined in ARGUMENTS.
I try also using XMLParse without luck.
Any ideas?
Thanks
