ColdFusion 9: onCFCRequest and Flash Remoting

ColdFusion 9 introduced the new onCFCRequest method. Unfortunately, this new method breaks Flash Remoting requests. To get around this issue you can resort to a modified version of the old onRequest hack. If you have an Application.cfc that covers remote components that will be used for Flash Remoting, you can add the following to your onRequestStart method:

<cffunction name="onRequestStart">
<cfargument name="targetPage" />

<cfif findNoCase("/flex2gateway",arguments.targetPage) gt 0>
<cfset structDelete(variables,"onCFCRequest") />
<cfset structDelete(this,"onCFCRequest") />

This will remove the onCFCRequest method for the current request and allow your Flash Remoting call to work. (Note: you may need to search for different paths depending on your BlazeDS endpoint configurations. If you don't know what I'm talking about here you will most likely be fine with the default "/flex2gateway".)

Ben Nadel's Gravatar I am not too versed in Flash. What kind of data is flash remoting looking for? Is this the process that uses AMF?
# Posted By Ben Nadel | 8/4/09 5:17 PM
Nathan Mische's Gravatar @Ben - Yes, in ColdFusion 9 this is the Flash/Flex communication done via BlazeDS.
# Posted By Nathan Mische | 8/4/09 6:35 PM
Ben Nadel's Gravatar @Nathan,

Ah, ok. I wish I was more familiar with that stuff.
# Posted By Ben Nadel | 8/5/09 8:31 AM
Rupesh Kumar's Gravatar @Nathan,
We are aware of this issue and we will be fixing this.
# Posted By Rupesh Kumar | 8/6/09 2:08 AM
Nathan Mische's Gravatar @Rupesh - Awesome news! Thanks for the update.
# Posted By Nathan Mische | 8/6/09 8:28 AM
Ron Pasch's Gravatar Seems it doesn't break it, but works in a way that onRequest works as well. Without including the targetPage yourself, onRequest will return nothing as well.

When I do this:

<cffunction name="onCFCRequest">
   <cfargument name="component" />
   <cfargument name="methodName" />
   <cfargument name="argcol" />
   <cfinvoke component="#arguments.component#"
method = "#arguments.methodName#"
returnVariable = "result"
argumentCollection = "#arguments.argcol#">
   <cfreturn result />

Flash Remoting calls work just fine. The only thing I'm worried about is that this is not documented whatsover and there is no returnType anymore.

Besides this, is there another way to get the AMF details in onRequestStart? (also in cf8) Perhaps through some java objects?
# Posted By Ron Pasch | 12/29/09 8:48 AM's Gravatar Many thanks for your post!!

I met the question about it and when I have no ideas I saw your blog!

# Posted By | 12/14/13 8:35 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.