September 27th, 2007 by Kyle
Tags: ColdFusion, flash-remoting, flashremoting, Flex, flex-data-services, flex-remoting, flex2gateway, gateway, remoting, rpc
Posted in: ColdFusion, Flex
I am using HostMySite as my web host and have the Linux Builder Plus CF package.
I haven’t upgraded to CF8 since that would require me to change my host package to use Windows. I don’t think I want that, since I like having SSH access to the machine my site is physically on.
I had just finished with my blog regarding Moving data from ColdFusion CFCs to Flex 2 Applications Using Webservices and was trying to get my code working on my site for the follow up article on Moving data from ColdFusion CFCs to Flex 2 Applications Using RemoteObject.
I was not being very successful and had even spoken with HostMySite support and they told me that accessing cfcs from Flex as RemoteObjects through the Flex Gateway with Coldfusion was not enabled and furthermore could not be enabled for a shared hosting account. If I wanted that functionality, I would have to upgrade to a VPS (Virtual Private Server) host package.
Now I pay about $65 per quarter for my host account for CF and WordPress capabilities. The base VPS host package with Coldfusion starts at $116 a month. I don’t know about you, but that is quite a jump for me, so I decided to do a bit more digging around. As it turned out, I found a few forum entries that seemed to allude that it was possible. In fact, one person had even posted to a link in his hosted site where he actually had my dev center article remote object sample working! Unfortunately he didn’t quite say how he had accomplished such a feat.
Well I knew how I would deal with that mystery. I got out my trusty Web Debugging Proxy tool: Charles to sniff the request that the sample was making so I could see what the url was to the flex gateway. As it turns out, I was just missing a trailing slash on my flex2gateway URI!!!!!
The key to getting this to work revolves around 3 things:
1. Getting your config files located and configured properly for compilation.
2. Getting the fully qualified name for your cfc correct.
3. Knowing the endpoint URI for your Flex Gateway fro your Coldfusion server.
In Flex Builder in my project, I create the following 2 config files:
services-config.xml:
<services-config>
<services>
<service-include file-path="remoting-config.xml">
</service-include>
<channels>
<channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://739saintlouis.com/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint">
<properties>
<polling-enabled>false</polling-enabled>
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>
</properties>
</endpoint>
</channel-definition>
</channels>
</services></services-config>
remoting-config.xml:
<service id="remoting-service">
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"></adapter-definition>
</adapters>
<destination id="ColdFusion">
<channels>
<channel ref="my-cfamf">
</channel>
<properties>
<source>**</source> <!–more–>
</properties>
</channels>
</destination>
</service>
In the compiler arguments for my Flex Builder project, I just added the compiler argument: -services services-config.xml
I am hosting my cfcs in a folder under the webroot of my site called services, so when I refer to my cfc in my remote object tag, you will note that the value for the source attribute is services.HelloWorld.
(You can see this in my blog entry: Moving data from ColdFusion CFCs to Flex 2 Applications Using RemoteObject)
Hope some of you find this info useful and if you have any comments or questions, just ask.
Tweet
No Comments »
