Using RemoteObject to access a Remote CFC

I get very closed minded sometimes… and this is one of those times… when working with flash remoting with the ColdFusion 7.0.2 updater, there were a lot of good examples on, I followed them a lot, they were all great… they specified how to create a connection like the following:

//create connection var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/"); //declare service var myService:mx.remoting.NetServiceProxy;

//make an object that will handle the response var responseHandler = {}; //function that receives the response responseHandler.onResult = function( results: Object ):Void { //when results are back, we show the text received display.text = results; } //function that receives any error that may have occurred during the call responseHandler.onStatus = function( stat: Object ):Void { //if there is any error, show an alert alert("Error while calling cfc:" + stat.description); } //get service. First parameter is path to component and //the second it's the object that will handle the response myService = connection.getService("flashRemotingResponder", responseHandler ); //make call myService.getDate(mask.text);

this code is great… you set up a service (called myService in this example, it’s calling a cfc called ‘flashRemotingResponder’)

When flex2 came out, and all of the examples starting coming out with it, and how to use it with ColdFusion, there were a lot of remoting examples using mx:RemoteObject… something like the following<mx:RemoteObject source="com.SomeCFC" destination="ColdFusion" result="someResultHandler(event)" fault="someFaultHandler(event)"/>

This is just psuedo code, so don’t copy and paste it… but I myself got caught up in this… we’ve recently been trying to hire another flex developer… we’ve got projects to do, and so we’re considering doing some contracting, but the problem is, we need someone that knows coldfusion and flex, and that seems to be a Hot combo right now, and most of the developers that know both of those things well are getting paid fairly well, and full of work… the point is, you can still use the RemoteObject tag to call cfc’s remotely, and call services like you used to be able to in flashremoting. you use the ‘endpoint’ attribute in remoteObject.

<mx:RemoteObject id="remoteService" source="com.test" destination="ColdFusion" endpoint="" result="onResult(event)" fault="onFault(event)"/>

You use the source like you would as if the objects are local to the webroot, and use the endpoint to specify a remote domain. This may be common knowledge to everyone out there, but I simply just forgot about even trying it… I got so caught up with having coldfusion locally installed, and working with the cfc’s myself, I simply got close minded about it…

anyway, check out the post about it at the following link, it’s where I got my answer.

1 comment on this post.
  1. Will:

    Thanx for the ‘endpoint’ – saved my skin!

Leave a comment