Hardly an answer to you question, but I spent a couple days beating my head against what seems to be this very same wall.
I have been wholly unable to return arrays of anything from webservices to a .NET client. I don't know if this applies to other situations, but it appears to be because CF arrays are untyped. Going through the CF and the C# line by line and everything is as it should be as near as I can tell, including the cast from Object to MyComponent when pulling values out of the array. However, it throws class cast exceptions on that cast, presumably because the .NET framework can't confirm that it's a valid cast, because CF isn't indicating that the contents of the array are anything more specific than Object. Cheers, barneyb > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Rick Root > Sent: Tuesday, May 25, 2004 4:49 AM > To: [EMAIL PROTECTED] > Subject: [CFCDev] Complex Datatypes in web services > > Okay, for those of you on CF-talk, I apologize, you've seen > this before. > I'm hoping that this list will prove to be more fruitful. > > I'm trying to write a web service that returns a complex > datatype (like > a struct but using a CFC instead), and one of the elements is > an Array > which contains complex datatypes. I need to make this > portable so that > a VB app can consume it (my prior solution when using Flash as the > consumer was to just return structs..) > > I was looking at the WSDL for the Google API, and it does > exactly what I > want to do. It returns a Complex Data Type named > "GoogleSearchElement", > which in turn contains a number of simple elements and a couple of > complex data type elements. One of these sub-elements is named > "GoogleSearchArray", a complex data type that is an array containing > another complex datatype "ResultElement". That's as far as I really > need to take this.. > > http://api.google.com/GoogleSearch.wsdl > > So anyway... I want to mimic this functionality... but I can't figure > out how. > > Here is my ReturnObject CFC that describes the complex data > type that I > want to return... a couple of strings and an array. > > <cfcomponent> > <CFPROPERTY NAME="ERRORCODE" TYPE="STRING"> > <CFPROPERTY NAME="ERRORMESSAGE" TYPE="STRING"> > <CFPROPERTY NAME="Results" TYPE="array"> > </cfcomponent> > > Now, I want the "Results" array to be an array of "ResultElement" > datatypes. so here is my ResultElement CFC... > > <cfcomponent> > <CFPROPERTY NAME="USERID" type="string"> > <CFPROPERTY NAME="FULLNAME" type="string"> > <CFPROPERTY NAME="TITLE" type="string"> > <CFPROPERTY NAME="DEPT" type="string"> > <CFPROPERTY NAME="PHONE" type="string"> > <CFPROPERTY NAME="FAX" type="string"> > <CFPROPERTY NAME="EMAIL" type="string"> > </cfcomponent> > > So next, I write a CFC that looks like this, called "directory.cfc" > > <cfcomponent hint="Authorization Functions" output="no"> > > <cffunction name="getAllUsers" access="remote" > returntype="ReturnObject" > displayname="getAllUsers" hint="getAllUsers"> > <CFSET retVal = > CreateObject("component","components.authorization.ReturnObject")> > <CFSET retVal.ERRORCODE = "0"> > <CFSET retVal.ERRORMESSAGE = "Success!"> > <CFSET retVal.Results = ArrayNew(1)> > <CFSET retVal[1] = > CreateObject("component","components.authorization.ResultElement")> > <CFSET retVal[2] = > CreateObject("component","components.authorization.ResultElement")> > <CFSET retVal[1].USERID = "rick"> > <CFSET retVal[1].FULLNAME = "Rick Root"> > <CFSET retVal[1].TITLE = "Coder"> > <CFSET retVal[2].USERID = "john"> > <CFSET retVal[2].FULLNAME = "John Doe"> > <CFSET retVal[2].TITLE = "Coder Assistant"> > <CFRETURN retVal> > </cffunction> > > </cfcomponent> > > This works fine if I implement it via an HTTP call... as in: > > http://www.ads.duke.edu/components/authorization/directory.cfc > ?method=getAllUsers > > So finally, I write a CFM to invoke the web service via a SOAP call. > > <cfinvoke > webservice="http://www.ads.duke.edu/components/authorization/d > irectory.cfc?WSDL" > > method="getAllUsers" > returnvariable="retVal"> > <CFDUMP VAR="#retVal#"> > > And I call it: > http://www.ads.duke.edu/components/authorization/directorytest.cfm > > UGLY! HORROR! YUCK! NASTY ERROR! > > - Rick [Todays Threads] [This Message] [Subscription] [Fast > Unsubscribe] [User Settings] > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
