Flex Data Server and CF Flash Remoting together

A common configuration question with Flex2 developers who are trying to use the Flex Data Server and CF is "How do I use FDS and Flash Remoting calls with CF, in the same app?". The reason this gets confusing is because both Flex and CF have their own version of the services-config.xml file, and you can only point to one file in your flex builder project. So which one do you use?

First off, do not try to merge the CF and Flex2 servers into the same instance. In other words if you find yourself trying to merge the web.xml files, like you did with CF and Flex 1.5 - STOP! Don't do it. You don't need to do it with flex2. Instead you want set up your servers and your project like this.

1) Configure CF on 1 instance/server
2) Configure FDS on 2nd instance/server
3) Point your project at the services-config.xml in the FDS instance.

Ok at this point you can easily call FDS destinations which uses CF (or not). Now to also make Flash remoting requests to CF.

4) Define the destination and channel with Actionscript, instead of letting the compiler do it when it is pointed at the CF version of the services-config.xml

To create you own ChannelSet the code would look something like this.



public var cSet:ChannelSet;

public function initApp()
{
cSet = new ChannelSet();
var customChannel:Channel = new AMFChannel("my-cfamf", http://localhost:8500/flex2gateway/);
// Add the Channel to the ChannelSet.
cSet.addChannel(customChannel);
foo.channelSet = cSet;
}


<mx:RemoteObject
id="foo"
destination="ColdFusion"
source="com.foo.component" />


Note: You can always use this ChannelSet technique instead of the -services compiler flag too. And you can use it, if you want to use something like FlashVars to dynamically change the endpoint url too.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
[Home]