Groups | Blog | Home
all groups > flash data integration > january 2005 >

flash data integration : How to access data returned from a webservice


joe28sfl
1/6/2005 2:09:28 AM
I have a webservice that returns a query containing information for a real
estate listing slideshow (picture, headline, sortorder). I have written the
actionscript to trigger the webservice and it appears to be working correctly.
When I run trace('results = ' + evtObj.target.results); I get the following
value back: results = [object Object],[object Object],[object Object],[object
Object],[object Object] I know that there are five records in the database so
I assume that each [object Object] represents one record. Question: How do I
get at the actual data in each record instead of just seeing [object Object]
????? Thanks for the help!
dbach
1/6/2005 11:00:41 AM
morksinaanab
1/6/2005 3:45:23 PM
You should know the attributes of the Object you are retrieving, to be able to
access these attributes. So if in your case the records are objects like Slide
you could try: evtObj.target.results[0].picture
evtObj.target.results[0].headline evtObj.target.results[0].sortorder
joe28sfl
1/6/2005 4:09:53 PM
morksinaanab, I tried using evtObj.target.results[0].Caption but it came back
as undefined when I traced it. Here is the code that I am using to run the
webservice. Can you see anything wrong with it? Function from the ColdFusion
webservice <cffunction name='getSlideShow' access='remote' returntype='query'>
<cfquery datasource='datasourceHere' name='qSlides'> Select FileName From
slideshowimages Where ClientID = 1 </cfquery> <cfreturn qSlides>
</cffunction> Here is the actionscript I'm using to trigger the service and
trace the results var ClientID:Number=1; this.slides_wsc.params=ClientID;
slides_wsc.trigger(); function traceStatus(evtObj:Object):Void {
trace(evtObj.code); if (evtObj.code=='Fault') {
trace(evtObj.data.faultcode); trace(evtObj.data.faultstring);
trace(evtObj.target.results); } } function traceResults(evtObj:Object):Void
{ trace('results = ' + evtObj.target.results); trace('first result = '
+evtObj.target.results[0].Caption); } slides_wsc.addEventListener('result',
traceResults); Here is what the trace from the traceResults function returns
results = [object Object],[object Object],[object Object],[object
Object],[object Object],[object Object],[object Object],[object Object],[object
Object],[object Object] first result = undefined Here is a summary of how I
have the webserviceConnector set up fieldname: params data type: Object storage
type: complex Any ideas why evtObj.target.results[0].Caption would come back
as undefined? I thought maybe my storage types for the webserviceConnector
might be wrong or something like that. Thanks
morksinaanab
1/7/2005 9:29:30 AM
Hi, the following query you use Select FileName From slideshowimages Where
ClientID = 1 should only return rows with one column 'FileName'; this does not
reflect the Caption you are talking about. What I usually do is create a local
object (Slide.as ?) as well, with the properties as on the server, so i can
instantiate the object as this local object. storage type Complex is ok..
(since it's an object) You could use your browser to get the WSDLURL and see
what it defines? Then you can see what kind of objects you should get back from
the Coldfusion server. Are you sure the property Caption exists in these
objects you are retrieving? (If you give me the URL, i could take a look at it?
mail me at harrie at quince dot nl)
AddThis Social Bookmark Button