ColdFusion Connectivity

One of the new features with Flex 2.0 is better connectivity with ColdFusion. Using ColdFusion MX with the 7.0.2 updater (or later) you can use RemoteObject to address your CFCs and exchange data structures. For example, a CFC that contains the results of query and that has functions to return the individual values (getter functions) can be mapped to an ActionScript 3.0 class with those getter functions as properties.

You can read more about it here:

As wonderful as it is, a number of people have had problems installing and getting it to work. The problem isn’t when you are working locally, but later when you deploy your Flex 2 SWF to your web server and your production CF is on another machine.

If you are using Flex Builder 2, you can take advantage of the CF connectivity plugin which has wizards to create CFCs from ActionScript 3 classes or vice-versa.

One of our Flex 2 forum users, JigHead, has kindly put his experience and instructions on the Flex 2 forum to help everyone out. I’ve copied those instructions here:

1.) Open the servics-config.xml file in C:\CFusionMX7\wwwroot\WEB-INF\flex\
and find and edit the vale for

<endpoint uri=”http://{}:{server.port}{context.root}/flex2gateway/” class=”flex.messaging.endpoints.AMFEndpoint”/>
<endpoint uri=”http://localhost/flex2gateway/” class=”flex.messaging.endpoints.AMFEndpoint”/>
port number is optional, 80 is default as usual.

2.) In FlexB right click your project folder and click properties > flex complier
and paste in this line in the addtional args field.

-services “C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml” -locale en_US.

That’s it!

However I believe there are bugs in FB2 to watch for. When you change the properties and click apply. The flex build path likes to reset the output folder to
c:\cfusionmx7\wwwroot\bin which then results in your page not loading 404 error in the browser. You will need to reset the path to your projects output folder again.

These issues with remoting are the reasons why all the FLEX examples show you how do do it in the cfroot rather than in your webroot. There are other pathing issues with flexbuilder2 as well that I found but thats for another topic.

Also check out this seminar if you can: