0

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?

Jason Towne
  • 8,014
  • 5
  • 54
  • 69
Kai
  • 376
  • 1
  • 4
  • 17
  • Ok, I fiddled around a bit: 'cs.addEventListener("channelConnect",handlechannel);protected function handlechannel(event:ChannelEvent):void{ if(event.connected){textfeld.text = "yay"}; } Showed me, that the channel doesnt connect. Dont understand why. – Kai May 21 '11 at 00:42
  • if you open your browser and type http://JESUSAGAIN/blazeds/messagebroker/amf are you receiving a 200 OK response code? – Cornel Creanga May 21 '11 at 10:03
  • Upon entering the URL it doesnt return any code. No errorcode at all. Why would that be important? As i said, it works in the mxml syntax and the blazeDS console for instance works, too. – Kai May 21 '11 at 10:14
  • 200 is not an error code, is the response returned to the browser if the endpoint exists. Why are you setting the source property? Is not supported by the Java adapter. Try like that: ro.myfunction() instead of the last 2 lines. – Cornel Creanga May 21 '11 at 10:25
  • Ok, I did. Same result. Nothing happens. THe DsConsole does show neither result nor faultevent. Its like the connection attempt wasnt even made. I also dont get an error string out of this, i have zero orientation... – Kai May 21 '11 at 10:45
  • You know, i thought about this. If i knew the source of the Obejct, I could figure it about by myself, since the remote object tag works. Is there any possibility the get the source code? – Kai May 21 '11 at 13:47
  • Yes, the flex sdk is open source. Are you using Flash Builder? If yes just press Ctrl+Click on the class name and you will see the source code. You can even modify it if you want. – Cornel Creanga May 21 '11 at 15:26
  • Im using Flexbuilder. - what do to now? – Kai May 21 '11 at 15:53
  • Go in your mxml file. Put the cursor on the class declaration (remoteobject). Press Ctrl+Left Click or F3. – Cornel Creanga May 21 '11 at 16:00
  • How very usefull! Ill be sure to post my results. Thank you! – Kai May 21 '11 at 16:05

1 Answers1

1

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.

Kai
  • 376
  • 1
  • 4
  • 17