bpurcell.org - Switching between webservices and Flash Remoting using Flex
Calendar
SunMonTueWedThuFriSat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Subject Archives
Amazon EC2 (15)
ColdFusionMX (155)
Corvette (3)
Flash Lite (4)
Flash Media Server (5)
Flash Player (3)
Flex (39)
General Web Dev (14)
HDTV (3)
Jboss (1)
Jquery (2)
JRun (59)
Max 2003 (3)
Other (33)
PC Hardware (16)
Software (17)
SpatialKey (7)
Wireless (8)
Working Out (1)

RSS Feed
Feed Listing

Site Contents
Home
My Blog
ColdFusion
JRun
Flex
Wireless & Networking
Hardware & Gadgets
HDTV
Software Picks
Pictures
Contact Me
Search


My Articles & Papers
Flex Performance
Server/Client
mm.com Under the Hood
Multiple Instances of CFMX
Multiple Instance Config
NLB with ColdFusion
Clustering CFMX for J2EE
Multi-Tier Hardware LB w CFMX
Cisco CSS & Coldfusion MX
JRun 4 Jini based Clustering
WiFi Growth

2ID Tacweb

Other Hobbys
Body-For-Life Challenge

Personal Projects
Family Pool
Deck Gate

username:
password:
 

 
Viewing Individual Entry / Main
April 2, 2004

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

<mx:WebService id="usersCFC" 
wsdl="http://127.0.0.1/myappdir/components/mycfc.cfc?wsdl"
showBusyCursor="true">
 <mx:operation name="getAllUsers"
result="userModel.userResultHandler(event.result)"
fault="userModel.userFaultHandler(event.fault)"/>
</mx: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

<mx:RemoteObject id="usersCFC" 
endpoint="http://127.0.0.1/flashservices/gateway"
source="myappdir.components.mycfc"
   showBusyCursor="true">
 <mx:method name="getAllUsers"
result="userModel.userResultHandler(event.result)
fault="userModel.userFaultHandler(event.fault)"/>
</mx:RemoteObject>

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.

Comments

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.

Thanks


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 ?

Regards


 
Page Render Time:93