all groups > macromedia flash flash remoting > november 2006 >
You're in the

macromedia flash flash remoting

group:

problems reading object arrays returned via remoting


problems reading object arrays returned via remoting enantiomer
11/18/2006 8:50:10 PM
macromedia flash flash remoting:
I am new to flash remoting and am testing that remoting can interface
with my business services and objects for a project that I am
interested in. The problem is that although I can communicate with the
server on simple assembly service method calls, when i try to return an
array of objects, it says what the correct length is, but returns
"nothing" when i try to trace the values in the debugger! Some help
would be appreciated. I am making assembly calls on my c# .net service
with flash mx. Below is my code:

Client code
----------------------
import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;

// fire up the output to the NetConnection debugger
mx.remoting.debug.NetDebug.initialize();


var newService = new Service("http://192.168.1.100/gateway.aspx", null,
"FlashRemoting.RemotingExample.EchoTest", null, null);

var pc:PendingCall = newService.GetPeople();
pc.responder = new RelayResponder(this, "onRemotingResult",
"onRemotingFault" );


function onRemotingResult(re:ResultEvent):Void
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There was no
problem: " + re.result });
trace(re.result.length);
trace("re = "+re[i]);
for(var i=0; i < re.result.length; i++){
trace("event name = "+re.result[i].Name);
}//for
}

function onRemotingFault(fe:FaultEvent):Void
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There was a
problem: " + fe.fault.faultstring });
trace(fe.fault.faultstring);
}

And the Server code
-----------------------------
using System;
using FlashGateway.IO;


namespace FlashRemoting.RemotingExample
{
///
/// Summary description for Class1.
///
public class EchoTest
{
public EchoTest()
{
//
// TODO: Add constructor logic here
//
}
public string echoString(string s)
{
s += " , hello";
return s;
}

public Person[] GetPeople()
{
Person[] people = new Person[2];
Person person = new Person();
person.Name = "Jon";
people[0] = person;
person = new Person();
person.Name = "Dave";
people[1] = person;
return people;
}
}
}
Re: problems reading object arrays returned via remoting enantiomer
11/18/2006 8:51:27 PM

Forget to show the trace output. The "2" is the length as shown in the
above code.
------------------------------------------------
2
re = undefined
event name = undefined
event name = undefined
Re: problems reading object arrays returned via remoting enantiomer
11/18/2006 9:07:22 PM
And I have more info here. From the NetConnection Debugger, I get the
following data. It looks like null values are being passed in, but i
have tested this method with a simple aspx page and it works fine.

1
------------------------------------------------------------------------------------
DebugId: "0"
EventType: "Call"
MethodName: "FlashRemoting.RemotingExample.EchoTest.GetPeople"
MovieUrl: "file:///D|/Documents and Settings/Jonathan/My
Documents/Visual Studio 2005/WebSites/RemotingTest/PumaEvents.swf"
Protocol: "http"
Source: "Client"
Time: 1163912653484
Date (object #1)
......"Sat Nov 18 21:04:13 GMT-0800 2006"
Parameters (object #2)
......No properties

2
--------------------------------------------------------------------------------------
DebugId: "0"
EventType: "Result"
MovieUrl: "file:///D|/Documents and Settings/Jonathan/My
Documents/Visual Studio 2005/WebSites/RemotingTest/PumaEvents.swf"
Protocol: "http"
Source: "Client"
Time: 1163912655015
Date (object #1)
......"Sat Nov 18 21:04:15 GMT-0800 2006"
Result (object #2)
......[0]: (undefined)
......[1]: (undefined)
Re: problems reading object arrays returned via remoting enantiomer
11/18/2006 11:06:29 PM
More curiosities. I have verified that I can fill a Datatable and
return it with data successfully entered in for every row. It is
curious that custom objects are causing problems where a datatable
doesn't.

Could it be because Datatable implements ISerializable or some other
interface?

Need help!! Thanks,
Re: problems reading object arrays returned via remoting enantiomer
11/19/2006 6:25:47 PM
So, I got it and only two days wasted.

In order to pass your .Net objects to flash, they first need to be
converted to an ASObject type. This is basically just controlling how
they are serialized. Why they didn't choose to rely on ISerializable
beats me.

This document says it all:

http://livedocs.macromedia.com/flashremoting/mx/Using_Flash_Remoting_MX/usingFRNET6.htm#1178906
AddThis Social Bookmark Button