Flex RemoteObject if ColdFusion isn't on your workstation

April 10, 2009

Here's a quick tip if you write Flex applications that talk to ColdFusion via RemoteObject calls and you don't have ColdFusion installed on your workstation.

When you create a Flex Builder project, set the "Application Server Type" to none. This means that Flex Builder doesn't need to be able to access you ColdFusion install (to read services-config.xml). Now all you need to do is set up an endpoint in your code.

This can be done as an attribute of you RemoteObject tag like this:


<mx:RemoteObject id="svcColdFusion" destination="ColdFusion" endpoint="http://myservername/flex2gateway/" />

Or if you prefer, in actionscript:


svcColdFusion:RemoteObject = new RemoteObject( "ColdFusion" );
svcColdFusion.endpoint = "http://myservername/flex2gateway/"

If you don't want to hard code your domain name, then you can always create the endpoint dynamically:


svcColdFusion.endpoint = "http://{server.name}:{server.port}/flex2gateway/"

If I'd known this when I started using Flex to call ColdFusion I'd have saved hours!


7 comments

  1. Does that mean i can use resources from anywhere?

    Such as: www.aliaspooryorik.com/flex2gateway/ />
    ??

    It's kinda weird to be able to do that huh?

    Comment by
    Marcos Placona – April 21, 2009
  2. Yes Marcos, it does mean that (even using services-config.xml and/or --services compiler argument you could do this).
    And that is why security is important :-)
    I'm talking about how ColdSpring's AOP system can help with this at the end of my SOTR talk in Manchester :-)

    Comment by Tom Chiverton – April 21, 2009
  3. Hi Marco, as Tom said (thanks for the comment Tom!) you can do that, although you will probably run into a security sandbox issue. That's where a cross-domain-policy.xml file can be used.

    Comment by John Whish – April 21, 2009
  4. Thought note that cross-domain XML files wont help if the developer chooses to proxy the requests through their own systems...

    Comment by Tom Chiverton – April 21, 2009
  5. Thought note that cross-domain XML files wont help if the developer chooses to proxy the requests through their own systems...

    Comment by Tom Chiverton – April 21, 2009
  6. Hmmm, good point Tom, I guess a malicious user could do that. I'm going to SOTR London so you'll have to post your slides!

    Comment by John Whish – April 21, 2009
  7. Thanks for the pointer. I've been searching the web for an example of how to connect to coldfusion running on a remote machine and you are the first one that gave a straight forward answer.

    Comment by Sean Sekora – June 07, 2009

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.