Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Remoting / November 2006



Tip: Looking for answers? Try searching our database.

problems reading object arrays returned via remoting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
enantiomer - 19 Nov 2006 04:50 GMT
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;
       }
   }
}
enantiomer - 19 Nov 2006 04:51 GMT
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
enantiomer - 19 Nov 2006 05:07 GMT
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)
enantiomer - 19 Nov 2006 07:06 GMT
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,
enantiomer - 20 Nov 2006 02:25 GMT
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/usingFRN
ET6.htm#1178906

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.