This questions is discussed in many places, but none of the solutions seem to work for me. Heres the thing: In my mxml-code everything works perfectly:
<s:RemoteObject id="remotetest" destination="Hibernatetest" endpoint="http://praiseJESUS/blazeds/messagebroker/amf" result="remotetest_resultHandler(event)" fault="remotetest_faultHandler(event)"/>
<s:Button x="1248" y="401" label="Laden" click="remotetest.getCells()"/>
protected function remotetest_resultHandler(event:ResultEvent):void
{
var cellList:ArrayCollection = event.result as ArrayCollection;
}
Now, this works perfectly. What doesnt work on the other hand is this:
var ro:RemoteObject = new RemoteObject;
var cs:ChannelSet = new ChannelSet;
var c:Channel = new AMFChannel("my-amf","http://JESUSAGAIN/blazeds/messagebroker/amf");
cs.addChannel(c);
ro.channelSet = cs;
ro.destination = "MyClass";
ro.source = "myNamespace.MyClass";
ro.getOperation("myfunction()").send();
This SHOULD work - dunno why it doesnt. Any hints?
Upon inspecting the code of the RemoteObject, i found the following code snippet:
mx_internal function initEndpoint():void
{
if (endpoint != null)
{
var chan:Channel;
if (endpoint.indexOf("https") == 0)
{
chan = new SecureAMFChannel(null, endpoint);
}
else
{
chan = new AMFChannel(null, endpoint);
}
channelSet = new ChannelSet();
channelSet.addChannel(chan);
}
}
This shows, that if an endpoint is defined, the RemoteObject-Class will create its own channelset. Allthough it might seem that this is the same as what I did, i cannot be, for the following piece of code actually works, unlike my first attempt.
var ro:RemoteObject = new RemoteObject("Hibernatetest");
ro.endpoint = "http://Jesus/blazeds/messagebroker/amf";
ro.myfunction();
Its seems one has to take great care when one defines the channelset. Maybe someone can enlighten me regarding this matter.