I was writing an application in Flex using ColdFusion as the backend. I first started using Webservices for my implementation and was wondering if I could easily switch it to Flash Remoting without modifying any of my other code. After all with CF, a CFC can be exposed either by web services or by Flash Remoting without any changes on the CF end.
My initial code looked like the following in Flex that called the CFC as a webservice
Notice I am just pointing the wsdl in the WebService tag directly at CF. Now if I want to use the ColdFusion Flash Remoting gateway instead, I don't have to change any of my other code in my MXML document. I just need to change the data tag. I just comment out the mx:WebService tag and replaced it with the following
Notice that I am not using the AMF implementation that ships with Flex. Instead I am using the CF flash gateway by modifying the endpoint attribute in the mx:RemoteObject tag.
The only issue that I ran into when doing this was with CF's handling of webservices. All variables returned from a CF webservice are uppercase even if they are not in the cfc file. With Flash remoting they are returned exactly as they are written. MXML is case sensitive so you may run into an issue here. Otherwise I found that this worked very well. Pretty cool!!!
**Late addition to this entry: I recieved an email noting that if you use Remoting with the endpoint attribute you will not use the proxy that is built into Flex. If the Flash Remoting server is on a different domain from the originating domain the Flex SWF was loaded from then a crossdomain.xml file needs to be used. You can find details on the crossdomain.xml file in the Flash livedocs. Basically you will run into a problem if Flex is on one machine and ColdFusion is on another. It is also worth taking a look at this Flash Devnet article for a second explanation of crossdomain.xml.
Would it be possible to use Remote Object with a CFC? As far as i know are CFC's and other CF code compiled to Java classes?
Are there other ways of calling a CFC in Flex and how? Can the AMF implementation that ships with Flex be used as well.
In the example from the blog posting I am using mx:RemoteObject with a CFC. I am not using the Flex AMF implementation though I am using the endpoint attribute to point it to the ColdFusion Flash Remoting Gateway. The Flex AMF implemention is for Java objects deployed in the Flex Application and does not support invoking CFC's. Although if you integrate CF and Flex into the same application you will have both (CF & Flex) Flash Remoting Implementations deployed and since they are deployed with different servlet mappings you can use them independently.
Do you know if using mx:RemoteObject with the ColdFusion Flash Remoting Gateway works with CFLOGIN authentication? A custom login prompt rather than the web browser's built-in prompt? I'm interested in your thoughts on how to do authentication of a Flex app with a CF back-end.
Is there an upgrade or a possible fix that will be coming from Macromedia anytime soon, that will allow a more ease of use of Remoting and Flash/Flex to be on different servers?
I am trying the cairngorm framework for flex, and was wondering if I could map cfc's to as2 classes. I found a positive answer (http://www.richinternet.de/blog/index.cfm?entry=74BA931D-C3DA-FDE0-C7959146205942DA)
Now, you say that the case is respected with remoting, and they seem to say the opposite. Is it something that was fixed by Flex1.5 and/or CF7 ?