Connecting Abobe AIR (beta) to Coldfusion via mx:RemoteObject
Kalen Gibbons
While Flex 3 and AIR are still in beta, there are lots of little bugs and quirks that need to be worked around. Today I was porting over a Flex application to AIR, and received an error whenever using mx:RemoteObject. It looked something like the following:
[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://myApp-debug.swf/flex2gateway/'"]
I searched for hours and hours trying to find out why my application worked correctly as a regular Flex application but not as an AIR app. I finally stumbled upon the solution and I thought I would share... in order to save everyone else the same headache. The key is to explicitly specify the endpoint attribute in the RemoteObject tag. If you are testing locally it may look something like this:
<mx:RemoteObject
id="AIR_Service"
destination="ColdFusion"
showBusyCursor="true"
endpoint="http://localhost:8500/flex2gateway"
source="myApp.cfc.cfcName" />
This is something I hope Adobe will fix before the official release of both these applications, but in the meantime, here is your workaround.
Update: After working with AIR for a while, I realize, of course, that this is not actually a bug. AIR does not have the same server context that Flex has, and therefore, an endpoint is required. The thing to remember when porting an application from Flex to AIR is not to forget the endpoint, or AIR won't know what server it is supposed to connect to.