Flex 2.0 with CFMX 7.0.2 - SUCCESS!!

Hurray! I finally was able to make Flex 2 work tonight with CFMX 7.0.2 on a remotely hosted, shared server. No more Unknown destination 'ColdFusion' errors!! Here's how I did it:

1. On the local machine without CFMX 7.0.2, put the default services-config.xml file (from CFMX 7.0.2) into: C:\CFusionMX7\wwwroot\WEB-INF\flex (create the folder, if you don't have it already).

2. When you create your flex app, specify the following by right-clicking on the application name (from within the Navigator in the top-left box) and choosing properties:

a. Flex Compiler tab -> Additional compiler arguments ->

-services "C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml" -locale en_US
b. Flex Server tab -> Flex root folder: c. Flex Server tab -> Flex server URL:

3. Now, FTP up your cfc into the folderofyourapp folder.

4. In your flex app, reference your RemoteObject's source as folderofyourapp.cfcname (without the .cfc at the end)

5. When you Save and Run your app in flex, you'll need for FTP up the .html and .swf files into your folderofyourapp/projectname/bin/filename (.html and .swf) and then Run again to actually see them.

This requires NO editing of the services-config.xml file.

Notes:

1. By using Web Services (mx:WebService tag) you don't need to do anything at all with this. Just point to the wsdl file and you're all set. However, this uses bloated XML for moving the data.

2. You can try to set your endpoint in the mx:RemoteObject, but this will use regular old flash remoting (the old one prior to Flex 2) which is better than XML, but aparently not compacted binary.

3. Using the method I described above uses AMF the new flash binary compressed format, which should be much faster and allow for future integtraion of Flex Data Services.

Thanks to Jeff Houser for his great article at: http://coldfusion.sys-con.com/read/256202.htm

Thanks also to everyone who tried to help me figure this out at: http://www.forta.com/blog/index.cfm/2006/2/1/ColdFusion-Flex-2-Sample-Application and http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1169105&highlight_key=y&keyword1=7%2E0%2E2

Please comment on this entry, if you found this a useful way to run Flex 2 and Cold Fusion MX 7 together.

Comments
Charlie Arehart's Gravatar Very nice, Ken. Glad to see it was finally sorted out. You have unlocked the door that I was alluding to in my comment in Ben's entry:

"I wonder if all this issue simply boils down to (all of) us needing help better understanding what parts of the Flex Builder Wizard setup steps regard the config of the local machine on which development is taking place versus what parts relate to the actual server on which deployment will take place.

Looking at it another way, many have used RDS features in connection with a localhost to do page creation, and then later deployed that code on a remote server. What we have here is an obvious need to get more info on what parts of the setup of the wizard need to reflect the server WHERE THE CODE WILL BE DEPLOYED."

That Flex Server Tab entry for the Flex server URL seems to be the key, right?.
# Posted By Charlie Arehart | 8/10/06 1:34 AM
Kenny Silanskas's Gravatar Ken,

I have been trolling your posts for hours now and I am facing a major problem. My web host is using CF 7.0.1 (the update to 7.0.2 is being applied), but I cannot wait for them to update before I deploy some portions of my app.

Would you happen to know how I can use Flex 2 with that version for remoting? I know you mentioned setting the endpoint, but when I do, I am faced with the TypeError #1034, implicit coercion error.

Am I going to be forced to use Web Services to connect to my CFCs?
# Posted By Kenny Silanskas | 8/11/06 11:40 AM
Ken Reiss's Gravatar Kenny Silanskas:

I'm sorry - I haven't successfully run it with the old flash remoting Endpoint, but have been told it should work.

Perhaps Jeff or Charlie has successfully done this and can chime in?
# Posted By Ken Reiss | 8/13/06 11:23 PM
Ken Reiss's Gravatar Yes, Charlie, you were right about where the line is drawn between local and remote. It's easy when it's all on your local machine, but for a real/live app, it has to be separated.

Homestly, I'm amazed at how much time this took me to do! It seems like everyone who's building Flex apps would have the same problem. However, it was very reassuring that Peter Ent mentioned that Adobe will add my steps into their next set of documentation!

I agree, too, about the wizard (etc.) being focussed on where the code will be deployed. Just makes sense to me. Yes, the 'Flex Server Tab -> Flex Server URL' was the key. Strangely enough, however, the services-config.xml (which is part of CFMX 7.0.2) file needs to be on your LOCAL machine for compile, even if you don't have any CF running locally. Then (I think) it uses the values from the Flex Server URL field to fill in those special variables (server) that everyone else is trying to set manually.

It occurred to me that there may be many people who don't have the ability to pull down this file from a real CFMX 7.0.2 box, so I'll put the original one here below.

Put the following file (in the next comment) in: C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml on your LOCAL machine (create the necessary folders, if needed). Technically, this file can be anywhere, as long as you specify it in your 'Flex Compiler tab -> Additional compiler arguments' field, but I just put it in the default location to make things simpler.

Well, I tried to put the code in here, bur for some reason the <code> blog tag didn't work here. I moved it to it's own separate comment below.

I hope this has been helpful to someone else like me who spent 2 months trying to figure out this stuff (which should have been automatic and/or obvious on day-1!).

Ken.
# Posted By Ken Reiss | 8/13/06 11:35 PM
Ken Reiss's Gravatar <?xml version="1.0" encoding="UTF-8"?>
<services-config>

<services>
<service id="coldfusion-flashremoting-service"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">

<adapters>
<adapter-definition id="cf-object" class="coldfusion.flash.messaging.ColdFusionAdapter" default="true"/>
</adapters>

<destination id="ColdFusion">
<channels>
<channel ref="my-cfamf"/>
</channels>
<properties>
<source>*</source>
<!-- define the resolution rules and access level of the cfc being invoked -->
<access>
<!-- Use the ColdFusion mappings to find CFCs, by default only CFC files under your webroot can be found. -->
<use-mappings>false</use-mappings>
<!-- allow "public and remote" or just "remote" methods to be invoked -->
<method-access-level>remote</method-access-level>
</access>

<property-case>
<!-- cfc property names -->
<force-cfc-lowercase>false</force-cfc-lowercase>
<!-- Query column names -->
<force-query-lowercase>false</force-query-lowercase>
<!-- struct keys -->
<force-struct-lowercase>false</force-struct-lowercase>
</property-case>
</properties>
</destination>

</service>
</services>

<channels>
<channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>
</properties>
</channel-definition>
</channels>

<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Error">
<properties>
<prefix>[Flex] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
<pattern>Message.*</pattern>
</filters>
</target>
</logging>

<system>
</system>

</services-config>
# Posted By Ken Reiss | 8/13/06 11:38 PM
Charlie Arehart's Gravatar Good to see the addtional thoughts, Ken. Might even be worth an additional blog entry, for those who might miss it in the comments here. To your and Kenny's question about whether all this should work with Flash Remoting before 7.02, I'm surprised to hear you say you heard it might. One of the primary points of 7.02 was the upgrade of FR to work with Flex 2. It's my understanding, as Kenny suggested, that prior to that (7.01, 6.1 or 6, or BlueDragon) you'd have to use web services instead. Not the end of the world; just not as seemless as the FR integration.

For those who would be interested, and as most CF-related Flex 2 articles do highlight the usee of FR via 7.02, it would be helpful to point out some articles on doing integration via web services. Ken, you've mentioned in the comments on Ben's blog that you've previously worked with Flex and web services. Do you have any good references to point folks to? Kenny? I did some digging and found that the bottom of this article (on Flex 2 and 7.02) does indeed show also how to change it to do web services as well:

http://www.adobe.com/devnet/flex/articles/hellowor...

I would suspect there were others posted in the time between Flex 2 being released and the 7.02 updater (or the early release of the "the CF adapter" which it included).
# Posted By Charlie Arehart | 8/14/06 9:24 AM
enzo's Gravatar Ken,

I am having trouble getting this to work. I am developing everything locally (using IIS w/ CF Developer Edition) and I cannot get rid of this error. Any ideas would help greatly. Is their something I missed during the install?
# Posted By enzo | 10/10/06 10:05 AM
Axel Jensen's Gravatar Hey Ken,

GOOD WORK ON FOLLOWING THROUGH!

I made a tutorial after following the steps you advised.

<a href="http://axel.cfwebtools.com/index.cfm/2006/12/13/Im..." target="_blank">http://axel.cfwebtools.com/index.cfm/2006/12/13/Im...</a>

the tutorial is on that page...
# Posted By Axel Jensen | 12/13/06 11:20 AM
Dan's Gravatar Thanks for the illumination!

What I'd like to know is how to get the wizard to generate the code so that it points the remote object to the correct source without having to do a search and replace each time I need to regenerate the code:

Example:
my APP ROOT:
http://localhost/sites/flex/db1
the file location:
is c:\sites\flex\db1

App Wizard Assumes it's being deployed off the webroot.

Realistically, most of us don't expect to deploy their crud apps off the webroot. More likely scenerio we'd deploy webroot /admin or /webapps or /flex etc.

So is this a limitation of the app wizard? Or can one "configure" the wizard to use a more accessable webroot and site folder?



Examples:

One needs to change this:
<mx:RemoteObject
      id="dataManager"
      showBusyCursor="true"
      destination="ColdFusion" source="db1.components.cfgenerated.companies">
      <mx:method name="getMasterQuery" result="getMasterQuery_result(event)" fault="server_fault(event)" />
      <mx:method name="deleteItem" result="deleteItem_result(event)" fault="server_fault(event)" />
   </mx:RemoteObject>

to to this:

<mx:RemoteObject
      id="dataManager"
      showBusyCursor="true"
      destination="ColdFusion" source="sites.flex.db1.components.cfgenerated.companies">
      <mx:method name="getMasterQuery" result="getMasterQuery_result(event)" fault="server_fault(event)" />
      <mx:method name="deleteItem" result="deleteItem_result(event)" fault="server_fault(event)" />
   </mx:RemoteObject>
# Posted By Dan | 12/21/06 5:02 PM
# Posted By Axel Jensen | 12/26/06 11:24 AM
Paul's Gravatar Hi Ken,

I'm hosting with crystaltech.com and struggling to get the Phones app working.

You said:

"4. In your flex app, reference your RemoteObject's source as folderofyourapp.cfcname (without the .cfc at the end)"

Where exactly in the Server Properties do I enter this? I have three text entry boxes named:

Root Folder
Root URL
Context Root

Also, do I need to know where my CFIDE is located. One of the errors that was thrown up says it can't find the CFIDE path. Surely I would need to make changes to services-config.xml depending on where CFIDE is located.

Cheers,
Paul
# Posted By Paul | 3/28/07 12:38 AM
Paul's Gravatar I'm not getting the CDIFE errors now after I put the CFCs into the "rootofyourfolder" (as you called it). But now, after the loading bar completes, nothing appears, just a blank grey screen.
# Posted By Paul | 3/28/07 12:45 AM
pete's Gravatar I am having trouble getting this to work. I am developing everything locally (using IIS w/ CF Developer Edition) and I cannot get rid of this error. Any ideas would help greatly. Is their something I missed during the install?
http://www.dir-9.com
# Posted By pete | 11/22/07 8:06 PM
automotive repair manual's Gravatar I'm not getting the CDIFE errors now after I put the CFCs into the "rootofyourfolder" (as you called it). But now, after the loading bar completes, nothing appears, just a blank grey screen.

http://www.automotive-repair-manual.net/
# Posted By automotive repair manual | 1/10/08 9:39 PM
Usb pendrive's Gravatar Thanks for help, Keep up the good work.
# Posted By Usb pendrive | 1/21/08 3:54 PM
Still life Artist's Gravatar I am having trouble getting this to work. I am developing everything locally (using IIS w/ CF Developer Edition) and I cannot get rid of this error. Any ideas would help greatly. Is their something I missed during the install?

Andrzej Filipowicz
Still life Artist, still life art
http://www.andrzejfilipowicz.com
STILL LIFE PAINTING
http://www.life.e-phils.com
# Posted By Still life Artist | 1/24/08 3:17 PM