Blog

21Mar
2006
ColdFusion Flash Remoting Configuration in Flex 2 Beta 2

Several of you have contacted me with problems using Flex beta 2 to connect to ColdFusion via Flash Remoting. A couple of the issues turned out to be configuration problems in flex-enterprise-services.xml (installed under WEB-INF\flex, and needed by the Flex compiler). Here is the file as it works for me:

view plain print about
1<?xml version="1.0" encoding="UTF-8"?>
2<services-config xmlns="http://www.macromedia.com/2005/flex-service-config">
3
4 <services>
5
6 <service id="coldfusionsamples-service"
7 class="flex.messaging.services.RemotingService"
8 messageTypes="flex.messaging.messages.RemotingMessage">

9
10 <adapters>
11 <adapter-definition id="cf-object" class="coldfusion.flash.messaging.ColdFusionAdapter" default="true"/>
12 </adapters>
13
14 <destination id="ColdFusion">
15 <channels>
16 <channel ref="my-cfamf"/>
17 </channels>
18 <properties>
19 <source>*</source>
20 <!-- define the resolution rules and access level of the cfc being invoked -->
21 <access>
22 <!-- Use the ColdFusion mappings to find CFCs, by default only CFC files under your webroot can be found. -->
23 <use-mappings>false</use-mappings>
24 <!-- allow "public and remote" or just "remote" methods to be invoked -->
25 <method-access-level>remote</method-access-level>
26 </access>
27
28 <property-case>
29 <!-- cfc property names -->
30 <force-cfc-lowercase>false</force-cfc-lowercase>
31 <!-- Query column names -->
32 <force-query-lowercase>false</force-query-lowercase>
33 <!-- struct keys -->
34 <force-struct-lowercase>false</force-struct-lowercase>
35 </property-case>
36 </properties>
37 </destination>
38
39 </service>
40
41 </services>
42
43 <security>
44
45 <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>
46
47 </security>
48
49 <channels>
50
51 <channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
52 <endpoint uri="http://localhost:8500{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
53 <properties>
54 <polling-enabled>false</polling-enabled>
55 <serialization>
56 <custom-deserializer type="typed-object" class="coldfusion.flash.messaging.io.amf.serializers.TypedObjectDeserializer" />
57 </serialization>
58 </properties>
59 </channel-definition>
60 </channels>
61 <logging>
62
63 <target class="flex.messaging.log.ConsoleTarget" level="Debug">
64 <properties>
65 <prefix>[Flex] </prefix>
66 <includeDate>false</includeDate>
67 <includeTime>false</includeTime>
68 <includeLevel>false</includeLevel>
69 <includeCategory>false</includeCategory>
70 </properties>
71 <filters>
72 <pattern>Endpoint.*</pattern>
73 <pattern>Service.*</pattern>
74 <pattern>Configuration</pattern>
75 <pattern>Message.*</pattern>
76 </filters>
77 </target>
78
79 </logging>
80
81 <system>
82 <locale>
83 <default-locale>en</default-locale>
84 <supported-locale>de</supported-locale>
85 <supported-locale>fr</supported-locale>
86 <supported-locale>es</supported-locale>
87 </locale>
88
89 <redeploy>
90 <enabled>true</enabled>
91 <watch-interval>20</watch-interval>
92 <watch-file>{context.root}/WEB-INF/flex/flex-enterprise-services.xml</watch-file>
93 <touch-file>{context.root}/WEB-INF/web.xml</touch-file>
94 </redeploy>
95 </system>
96
97</services-config>
If you are not using ColdFusion's integrated HTTP server, be sure to change the port from 8500 (or just drop the port altogether if using port 80).

Comments (22)



  • rd

    Still having tons of problems on my home computer, but for reference. I installed everything on my work computer and remoting worked flawlessly out of the box (without editing any xml). So i'm thinking something is crufty on my home computer even after uninstalling cf and fb. Personally I think it had to do with the old Flex Enterprise Data stuff that I installed in prev beta (and have since uninstalled). I think something is hanging on to that rather than the remoting.

    #1Posted by rd | Mar 22, 2006, 11:02 AM
  • rd

    I think I have tracked the problem down to some missing lines in the web.xml file involving the flex2gateway. Not sure why after uninstalling everything, neither flex, cf, or the cf connector would add these lines. More info at:

    http://www.drisgill.com/index.cfm/2006/3/22/Flex-2...

    #2Posted by rd | Mar 22, 2006, 08:34 PM
  • Rich

    I am not having any trouble getting the Coldfusion/Flex Connection to work. I have a made a simple hello world that is able to pass data back and forth from a Flex Client to a .CFC. I just can't get any of your samples to work with Beta 2. I keep getting compile errors: Implicit coercion of a value with static type 'Object' to a possibly unrelated type 'Phone'   Main.mxml Phones line 37.

    #3Posted by Rich | Mar 24, 2006, 02:31 PM
  • Ben Forta

    Rich, is that where you are passing list.selectedItem (an object) to ProductDetails (which expects a Phone object)? If so, change {list.selectedItem} to {Phone(list.selectedItem)}, that casting should do it.

    --- Ben

    #4Posted by Ben Forta | Mar 24, 2006, 02:38 PM
  • Jeremy

    I too am having trouble with Flash Remoting in Flex 2 Beta 2. I have the Coldfusion/Flex Connection installed on Coldfusion MX 7 Stardard, and am using the Flex 2 Eclipse Plugin for development. When trying to run the Phones example I am only getting a busy cursor once the app loads. I have updated the flex-enterprise-services.xml file to reflect my configuration (IIS port 80). I have also added the --services argument to the compiler option. I have compared the FES file posted against mine with the only difference being the entpoint-uri.

    #5Posted by Jeremy | Mar 24, 2006, 03:34 PM
  • Muzak

    I kept getting an error like this when trying the new adapter:

    Error: faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 500'
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultH...()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.messaging::MessageAgent/fault()
    at mx.messaging::Producer/fault()
    at mx.messaging::ChannelSet/::faultPendingSends()
    at mx.messaging::ChannelSet/handleChannelFault()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.messaging::Channel/mx.messaging:Channel::connectFailed()
    at mx.messaging.channels::NetConnectionChannel/mx.messaging.channels:NetConnectionChannel::connectFailed()
    at mx.messaging.channels::AMFChannel/mx.messaging.channels:AMFChannel::statusHandler()

    Took me a while to figure out what was wrong, but when I checked the Coldfusion logs (JRUN4\logs\cfusion-event.log) i noticed the required JVM was not installed. The one that comes with JRUN4 apparently does not meet the required version.
    I installed JAVA SDK 1.4.2.11, changed the JVM in the JRUN administrator, restarted server and everything started working ;-)

    Also note that I changed the <endpoint> into: http://{context.root}/flex2gateway/
    That way I am able to connect from any PC on the network.

    Hope this helps,
    Muzak

    #6Posted by Muzak | Mar 27, 2006, 04:04 AM
  • Muzak

    Correction, the endpoint looks like this:

    <endpoint uri="{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint" />

    #7Posted by Muzak | Mar 27, 2006, 01:44 PM
  • Jeremy

    After finding more time I was able to finally get a gateway connection. My endpoint uri had to contain the actual host name like this: <endpoint uri="[HOST NAME]/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint" />. I had also Restarted the server after modifying the flex-enterprise-services.xml file. However, using ServiceCapture as a debug tool for the Remoting calls, the endpoint was NOT relecting my current changes. I'm not sure if it was time, or ONLY making enough modifications to the file and then clicking the Run icon in FB that finally the endpoint was corrected. Now that I have jumped this hurdle, I am encountering anothe issue: Could not find the ColdFusion Component CFIDE.samples.Phones.CF.Catalog. I have placed this sample in the default location, and the test.cfm file included runs fine. Any ideas?

    #8Posted by Jeremy | Apr 4, 2006, 11:42 AM
  • Ed Welch

    Ok..I have tried just about every combination that is listed here..so I will give my setup and see what everyone has to say..here is my error>
    Error: faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 500'
       at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultH...()
       at flash.events::EventDispatcher/dispatchEvent()
       at mx.messaging::MessageAgent/fault()
       at mx.messaging::Producer/fault()
       at mx.messaging::ChannelSet/::faultPendingSends()
       at mx.messaging::ChannelSet/handleChannelFault()
       at flash.events::EventDispatcher/dispatchEvent()
       at mx.messaging::Channel/mx.messaging:Channel::connectFailed()
       at mx.messaging.channels::NetConnectionChannel/mx.messaging.channels:NetConnectionChannel::connectFailed()
       at mx.messaging.channels::AMFChannel/mx.messaging.channels:AMFChannel::statusHandler()

    Here is my services entry
    --services=y:\CFusionMX7\wwwroot\WEB-INF\flex\flex-enterprise-services.xml

    I have a mapped drive from my laptop to the webserver and I am using Flexbuilder on my laptop not the webserver.

    My web site runs from the follwoing directory
    I:\inetpub\wwwroot

    Here is my endpoint from the enterprise-services.xml file
    <endpoint uri="http://localhost{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
    I have tried the following also:
    <endpoint uri="http://{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
    <endpoint uri="{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
    <endpoint uri="http://localhost:80{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
    <endpoint uri="http://intratest:80" target="_blank">http://intratest:80{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
    <endpoint uri="http://intratest{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>


    Any ideas on what the error is from...I am trying to run the Phones sample project. All the project files are located in I:\inetpub\wwwroot\CFIDE\samples\Phones

    Thanks for any help you can provide.
    Ed

    #9Posted by Ed Welch | Apr 7, 2006, 04:35 PM
  • Ed Welch

    Does anyone have any ideas about my previous post?

    Thanks

    #10Posted by Ed Welch | Apr 18, 2006, 11:40 AM
  • Ed Welch

    Here is a section from my coldfusion-event.log but I am still having problems with the endpoint port...

    04/18 15:05:27 user failed to load: flex.messaging.MessageBrokerServlet
    04/18 15:05:27 error Invalid endpoint port '' specified for channel definition 'my-cfamf'.
    [1]flex.messaging.config.ConfigurationException: Invalid endpoint port '' specified for channel definition 'my-cfamf'.
       at flex.messaging.config.ApacheXPathConfigurationParser.channelDefinition(ApacheXPathConfigurationParser.java:355)
       at flex.messaging.config.ApacheXPathConfigurationParser.channelsSection(ApacheXPathConfigurationParser.java:315)
       at flex.messaging.config.ApacheXPathConfigurationParser.parseTopLevelConfig(ApacheXPathConfigurationParser.java:130)
       at flex.messaging.config.ApacheXPathConfigurationParser.parse(ApacheXPathConfigurationParser.java:71)
       at flex.messaging.config.ApacheXPathConfigurationParser.parse(ApacheXPathConfigurationParser.java:61)
       at flex.messaging.config.ConfigurationManager.getMessagingConfiguration(ConfigurationManager.java:52)
       at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:54)
       at coldfusion.bootstrap.ClassloaderHelper.initServletClass(ClassloaderHelper.java:96)
       at coldfusion.bootstrap.BootstrapServlet.init(BootstrapServlet.java:48)
       at jrun.servlet.WebApplicationService.loadServlet(WebApplicationService.java:1242)
       at jrun.servlet.JRunRequestDispatcher.init(JRunRequestDispatcher.java:748)
       at jrun.servlet.JRunRequestDispatcher.<init>(JRunRequestDispatcher.java:98)
       at jrun.servlet.WebApplicationService.getDispatcher(WebApplicationService.java:865)
       at jrun.servlet.ServletEngineService$1.fetch(ServletEngineService.java:511)
       at jrunx.util.Cache.get(Cache.java:116)
       at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:537)
       at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
       at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
       at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
       at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
       at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    [0]javax.servlet.ServletException: Invalid endpoint port '' specified for channel definition 'my-cfamf'.
       at coldfusion.bootstrap.ClassloaderHelper.initServletClass(ClassloaderHelper.java:104)
       at coldfusion.bootstrap.BootstrapServlet.init(BootstrapServlet.java:48)
       at jrun.servlet.WebApplicationService.loadServlet(WebApplicationService.java:1242)
       at jrun.servlet.JRunRequestDispatcher.init(JRunRequestDispatcher.java:748)
       at jrun.servlet.JRunRequestDispatcher.<init>(JRunRequestDispatcher.java:98)
       at jrun.servlet.WebApplicationService.getDispatcher(WebApplicationService.java:865)
       at jrun.servlet.ServletEngineService$1.fetch(ServletEngineService.java:511)
       at jrunx.util.Cache.get(Cache.java:116)
       at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:537)
       at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
       at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
       at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
       at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
       at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

    any ideas?

    #11Posted by Ed Welch | Apr 18, 2006, 03:11 PM
  • Kevin Roche

    I have the same problem as Ben but with the Flex2 Beta3.

    The flex-enterprise-services.xml file looks quite different to the one above.

    There is no mention of the coldFusion service in there.

    Can anyone post a good copy from Flex2 Beta3 for me please?

    Kevin

    #12Posted by Kevin Roche | May 13, 2006, 07:22 AM
  • TOM

    can anyone explain me please how to use NetConnectionDebugger with flex2?

    #13Posted by TOM | Jul 24, 2006, 09:30 AM
  • enzo

    Ben,

    I just installed Flex 2, and have data connectivity between Flex and WebServices (CFC's). If I try to convert to using Flash Remoting I get the errors listed here. I have tried every configuration that I have found on the web but so far it has not worked. Any insight you may have would be a great help to me. I am new to Flex, but so far I am really enjoying how easy it is to program.

    #14Posted by enzo | Oct 10, 2006, 09:44 AM
  • Ben Forta

    Enzo,

    Are you using a locla CF server running 7.0.2? You should not need to worry about the issues raised in this thread in the final product. So long as Flex Builder can find the CF services-config.xml it should just work. This thread applied to the beta when stuff was not as simple.

    --- Ben

    #15Posted by Ben Forta | Oct 11, 2006, 11:51 AM
  • Pablo

    I'm having similar problems, with Flex Builder 2 and a local copy of CF 7.0.2. I've configured my services-config.xml to point to the local web server and host, but still no luck. Any ideas?

    [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed"]
       at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultH...()
       at mx.rpc::Responder/fault()
       at mx.rpc::AsyncRequest/fault()
       at mx.messaging::ChannelSet/::faultPendingSends()
       at mx.messaging::ChannelSet/channelFaultHandler()
       at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
       at flash.events::EventDispatcher/dispatchEvent()
       at mx.messaging::Channel/mx.messaging:Channel::connectFailed()
       at mx.messaging.channels::PollingChannel/mx.messaging.channels:PollingChannel::connectFailed()
       at mx.messaging.channels::AMFChannel/mx.messaging.channels:AMFChannel::statusHandler()

    #16Posted by Pablo | Oct 31, 2006, 11:28 AM
  • Ben Forta

    Pablo, can you make calls to the Flash Remoting 2 path without an error? Also, if you start CF in console mode are you seeing any useful log info?

    --- ben

    #17Posted by Ben Forta | Oct 31, 2006, 08:45 PM
  • Pablo

    Thanks for the quick response, Ben. I figured out the problem on my own: the ColdFusion setup was actually fine -- the problem was that my browser (Firefox 2) had cached the SWF from a previous build, where the flex/services-config.xml was pointing to the wrong place. I cleared out the cache, and everything started working.

    Thanks!

    #18Posted by Pablo | Nov 1, 2006, 03:32 PM
  • Sameer

    Hi! I am using Flex 3 beta remoting with CF MX 7.0.2 but keep getting "Send Failed" error.

    Here's snippet from C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml:

    The file originally contained:
    uri="http://{server.name}:{server.port}{context.root}/flex2gateway/"

    I changed it to:
    1. uri="http://localhost:8500{context.root}/flex2gateway/
    2. uri="http://localhost{context.root}/flex2gateway/

    Still no luck. Please help! Thanks.

    #19Posted by Sameer | Jan 25, 2008, 02:11 PM
  • Bob Klaas

    I am currently experiencing the same problem as Sameer. I developed a Flex application that retrieves data from a ColdFusion CFC by use of a remote object. I'm using Flex Builder 3 along with Coldfusion MX7. I am new to Flex and I am having a hard time trying to troubleshoot my problem. When I deployed the application on my local machine, everything worked perfect. The problem started when trying to deploy it to our company server. I keep getting a "send failed" error. I then tried to verify that my Flex gateway was working properly by entering http://www.my-website.com/flex2gateway/ in my browser. Sure enough I received a 404 error instead of a blank screen. I have saturated forums trying to figure out what I need to do in order to deploy this application. Everything I have tried seems to have a dead end. Halp!

    #20Posted by Bob Klaas | Apr 8, 2009, 06:46 PM
  • Bob Klaas

    Thanks to rd's post on 3/22, I've launched my first Flex application!

    If anyone runs into a Flex gateway 404 error, I suggest looking at the link below. It solved my gateway problem and I was able to launch my first Flex application.

    http://www.drisgill.com/index.cfm/2006/3/22/Flex-2...

    Thanks RD!

    Ben, I would like to thank you for supplying the public with a useful and detailed blog. I have solved many of problems here!

    #21Posted by Bob Klaas | Apr 9, 2009, 07:08 PM
  • rd (randy drisgill)

    Wow I can't believe that post so long ago is still helping folks. 2006! Glad it helped.