The Flex Journey Continues.....

Flex Add comments

Mostly I'm posting this here to chronicle my experience, but feel free to comment if you would like.

Ok, so I've been learning Flex in my spare time for a few weeks and have become okay when writing the basic stuff, but my real interest is in the remoting aspects. So I decided to try put a simple remoting application together. The goal is to create a page with just a button and a label. When the button is pressed, I want to communicate with a CFC that returns the current date and time.

So here's the Flex code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
   <mx:Script>
      <![CDATA[
         import mx.rpc.events.ResultEvent;
         
         public function eventSuccess(event:ResultEvent):void{
            lblStringResult.text = event.result as String;
         }
      ]]>
   </mx:Script>
   
   <mx:RemoteObject id="conn" destination="ColdFusion" source="cfflex.Demo1.Demo1CFC"
      result="eventSuccess(event)" showBusyCursor="true">

      
   </mx:RemoteObject>
   
   <mx:Label id="lblStringResult" y="10" horizontalCenter="0"/>
   <mx:Button label="Server Time?" click="conn.getServerTime();" y="36" width="100" horizontalCenter="0"/>
</mx:Application>

Pretty simple right? I have a mapping on the CF server with a logical directory of '/cfflex' and a directory path of '/Library/WebServer/Documents/svn/CFCLib' that contains a directory called Demo1 that, in turn, contains a CFC named Demo1CFC.cfc.

Here's the ColdFusion Code:

<cfcomponent output="false">
   <cffunction name="getServerTime" access="remote" returntype="string">
      <cfreturn now() />
   </cffunction>
</cfcomponent>

The problem is that every time I run the Flex page and press the button I receive the following error:

[RPC Fault faultString="[MessagingError message='Destination 'ColdFusion' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" faultCode="InvokeFailed" faultDetail="Couldn't establish a connection to 'ColdFusion'"]
   at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:257]
   at mx.rpc.remoting.mxml::Operation/http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\remoting\mxml\Operation.as:197]
   at mx.rpc.remoting::Operation/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:113]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at mx.rpc.remoting.mxml::Operation/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\remoting\mxml\Operation.as:170]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at mx.rpc::AbstractService/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AbstractService.as:285]
   at CFandFlex/___CFandFlex_Button1_click()[/Library/WebServer/Documents/svn/CFandFlex/src/CFandFlex.mxml:19]

My platform is an Intel Mac using Apache2 and ColdFusion 8 64bit.

1 response to “The Flex Journey Continues.....”

  1. jan Says:
    Hi Mike,

    Did you ever solve this ? I'm having exactly the same problem when trying some of the examples out there. (including the code you post here).

Leave a Reply





Powered by Mango Blog. Design and Icons by N.Design Studio