There is a client - server basic application. The client uses a simple remoting to comunicate with the server side. The server side could be powered on WebORB, BlazeDS or any other product. The client side is using the FLEX framework. That is it about a technologies stack. Now, let's forget about the server side and just have a look on the following client side
package com.blog.ri
{
import mx.collections.ArrayCollection;
public class MyCollection extends ArrayCollection
{
public function MyCollection(source:Array=null)
{
super(source);
}
}
}
Additionally, let's assume we have the following class and it is mapped to the server side class:
package com.blog.ri
{
[Bindable]
[RemoteClass(alias="com.blog.ri.MyEntity")]
public dynamic class MyEntity
{
private var _myCollection:MyCollection;
public function get myCollection():MyCollection
{
if(_myCollection == null)
_myCollection = new MyCollection();
return _myCollection;
}
public function set myCollection(value:MyCollection):void
{
_myCollection = value;
}
}
}
Also, the server side service expose for clients the void save(MyEntity candidate) method and I implemented it on the client side as it shown below:
package com.blog.ri
{
public class MyService
{
private var _remoteObject:RemoteObject;
public function MyService()
{
var channelSet:ChannelSet = new ChannelSet();
var amfChannel:AMFChannel = new AMFChannel("my-amf", "http://localhost/weborb.aspx");
channelSet.addChannel(amfChannel);
_remoteObject = new RemoteObject("GenericDestination");
_remoteObject.channelSet = channelSet;
_remoteObject.source = "com.blog.ri.MyService";
_remoteObject.getDetailedStatistic.addEventListener("result",onItemSaved);
_remoteObject.addEventListener("fault", onFault);
}
public function save(candidate:MyEntity, responder:IResponder = null ):void
{
var asyncToken:AsyncToken = _remoteObject.save(candidate);
if( responder != null )
asyncToken.addResponder( responder );
}
}
}
Finally, I tried to save a new instance of the MyEntity class in our main mxml file as it shown below:
protected function creationCompleteHandler():void
{
var myService:MyService = new MyService();
var candidate:MyEntity = new MyEntity();
candidate.myCollection = new MyCollection();
myService.save(candidate);
}
That is it. When I run the code, I received the following exception:
ArgumentError: Error #2004: One of the parameters is invalid. at flash.net::NetConnection/invokeWithArgsArray() at flash.net::NetConnection/call() at mx.messaging.channels::NetConnectionChannel/internalSend()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:281] at mx.messaging.channels::AMFChannel/internalSend()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:364] at mx.messaging::Channel/send()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\Channel.as:1002] at mx.messaging.channels::PollingChannel/send()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:394] at mx.messaging::ChannelSet/send()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1429] at mx.messaging::ChannelSet/channelConnectHandler()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1084] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.messaging::Channel/connectSuccess()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\Channel.as:1148] at mx.messaging.channels::AMFChannel/resultHandler()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:576]
As you can see, I extended the ArrayCollection class and according to the Adobe documentation, the ArrayCollection implements the IExternalizable interface. I decided to localize the problem and created a simple class that implements IExternalizable. Then, I extended this class in some other MyChild class and defined the MyChild property in the MyEntity class. In this case, I received the exception above as well. Is there a problem how I wrote the code or it is a bug within flex?
Thanks for any help. The question is duplicated in my blog.