This is kinda what we do, except we have a Gateway which accepts xml as input, you pass in the component/function you want to call, plus all the arguments etc. The system knows if and when you pass in incorrect params and handles it all for you...we have an External Request and an Internal Request method for deciding how to pass info/data back to the client.
All of it is logged (as XML and with a bank of custom error codes) which allows us to "replay" calls and processes for debugging. As noted, we have a nifty CFC to convert any and all CF objects (complex or otherwise) to XML (and back again if needs be) so the client will always get XML. I wouldn't trust passing back a ColdFusion object back at all, I would go with string XML 100%. "This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant, Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business, Registered in England, Number 678540. It contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender or call our switchboard on +44 (0) 20 89107910. The opinions expressed within this communication are not necessarily those expressed by Reed Exhibitions." Visit our website at http://www.reedexpo.com -----Original Message----- From: Ben Mueller To: CF-Talk Sent: Fri Mar 02 22:13:13 2007 Subject: Re: Create a webservice that returns a structure, to be consumed by ..NET After a bit of reflection, I'm taking both suggestions. Per Rick's suggestion, I'm creating a wrapper function that just calls the "real" function. The wrapper is the webservice version of the function, and takes all the "real" function arguments, and an additional "returnformat" argument. This argument can be, for now, "querystring","xml", or "struct". If the caller chooses querystring, then I return a URL encoded querystring for the results (replacing the ampersand with pipes as the outer delimiters). If the caller chooses xml, then I return xml as a string that the caller can then re-serialize into an XML document. If we have any partners that use CF, then they can get a struct back. Thanks to all for the advice. For anybody who's interested, here's my "formatreturn" code, plus one supporting function (note: this code only works on structures that have simple values--if the structure values are arrays, queries, etc, then this code bombs): <cffunction name="formatreturn" access="package" returntype="any" output="false"> <cfargument name="struct" type="struct" required="true"> <cfargument name="conversion" type="string" required="false" default="querystring"> <cfset var res = ""> <cfset var value = ""> <cfswitch expression=#arguments.conversion#> <cfcase value="querystring"> <cfloop collection=#arguments.struct# item="key"> <cfset value = structfind(arguments.struct,key)> <cfif NOT len(value)><cfset value="[empty string]"></cfif> <cfset res = listappend(res,"#key#=#value#","|")> </cfloop> <cfset res = urlencodedformat(res)> </cfcase> <cfcase value="xml"> <cfset res = this.structToXml(arguments.struct,"results")> </cfcase> <cfcase value="struct"> <cfreturn arguments.struct> </cfcase> <cfdefaultcase> <cfreturn ""> </cfdefaultcase> </cfswitch> <cfreturn res> </cffunction> <cffunction name="structToXML" returnType="string" access="package" output="false"> <!--- Apparently, using the underlying Java code is far faster than CF stuff ---> <cfargument name="struct" type="struct" required="true"> <cfargument name="rootelement" type="string" required="true"> <cfset var s = createObject('java','java.lang.StringBuffer').init('<?xml version="1.0" encoding="UTF-8"?>')> <cfset var key = ""> <cfset s.append("<#arguments.rootelement#>")> <cfloop collection=#arguments.struct# item="key"> <cfset key = lcase(key)> <cfset s.append("<#key#>#xmlformat(structfind(arguments.struct,key))#</#key#>")> </cfloop> <cfset s.append("</#arguments.rootelement#>")> <cfreturn s.toString()> </cffunction> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Macromedia ColdFusion MX7 Upgrade to MX7 & experience time-saving features, more productivity. http://www.adobe.com/products/coldfusion Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271393 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4