<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gruchalski.com &#187; Railo</title>
	<atom:link href="http://gruchalski.com/category/cfml/railo/feed/" rel="self" type="application/rss+xml" />
	<link>http://gruchalski.com</link>
	<description>confessions of a ria developer</description>
	<lastBuildDate>Sat, 08 May 2010 16:43:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Railo, BlazeDS and CFC instances</title>
		<link>http://gruchalski.com/2009/04/20/railo-blazeds-and-cfc-instances/</link>
		<comments>http://gruchalski.com/2009/04/20/railo-blazeds-and-cfc-instances/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 21:34:09 +0000</pubDate>
		<dc:creator>radekg</dc:creator>
				<category><![CDATA[Adobe Flex/AIR]]></category>
		<category><![CDATA[Railo]]></category>

		<guid isPermaLink="false">http://gruchalski.com/?p=103</guid>
		<description><![CDATA[There is a lot of buzz recently around Railo since version 3.1 finally went open source and many well known CF developers joined the project. This gave me the motivation to finally see how Railo really works. I decided to give it a shot on one of already running applications. The choice was made, I [...]]]></description>
			<content:encoded><![CDATA[<p>There is a lot of buzz recently around <em><a href="http://getrailo.org">Railo</a></em> since version 3.1 finally went open source and many <a href="http://www.markdrew.co.uk">well</a> <a href="http://www.pbell.com">known</a> <a href="http://corfield.org">CF developers</a> joined the project. This gave me the motivation to finally see how Railo really works. I decided to give it a shot on one of already running applications. The choice was made, I selected a Flex application powered by ColdFusion 8.1 utilizing Adobe ColdFusion classes, providing 20 different gateways, using ODBC data sources and operated with very rich and sophisticated Flex UI exchanging data using typed VOs.</p>
<p>First experience was great. No issues at all, application started very quickly, what takes about 20 seconds on ColdFusion is almost immediate on Railo. All CFCs worked fine, even those using internal ColdFusion classes. Overall performance was fantastic, all JDBC ODBC connections running smoothly. I have to admit that Railo guys have done really great job.</p>
<p>It was time to test Flex UI, a major issue popped out straight away. Railo provides integration with Adobe&#8217;s open source Blaze Data Services. It&nbsp;appears to work perfectly fine with all standard CFML types, strings, structures, arrays, etc., however not with CFCs. At the current state Railo is not able to serialize and deserialize them. Below is the sample test case.</p>
<p><em>Service.cfc</em> that Flex talks to:</p>
<pre>[source lang='cf']
<cfcomponent>

  <!---
    Accepts a CFC instance: --->
  <cffunction name="getCfc" access="remote" output="false" returntype="string">
    <cfargument name="inst" type="com.gruchalski.railo.test.TestCFC" required="true" />
    <cfreturn "ok" />
  </cffunction>

  <!---
    Returns a CFC instance on request: --->
  <cffunction name="outCfc" access="remote" output="false" returntype="com.gruchalski.railo.test.TestCFC">
   <cfset var inst = createObject("component", "com.gruchalski.railo.test.TestCFC") />
   <cfset inst.property1 = "Hello from Railo" />
   <cfset inst.property2 = 20 />
   <cfreturn inst />
  </cffunction>

</cfcomponent>
[/source]</pre>
<p>And here is the source of <em>com.gruchalski.railo.test.TestCFC</em>:</p>
<pre>[source lang='cf']
<cfcomponent>
  <cfproperty name="property1" type="string" />
  <cfproperty name="property2" type="numeric" />
  <cfset this.property1 = "" />
  <cfset this.property2 = 0 />
</cfcomponent>
[/source]</pre>
<p>To access the service I am using following Flex application:</p>
<pre>[source lang='as3']
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

  <mx:Script>
    <![CDATA[
      import mx.utils.ObjectUtil;
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;
      import com.gruchalski.railo.test.TestCFC;

      private function sendInst():void {
        var inst:TestCFC = new TestCFC();
        inst.property1 = "Ħello Railo!";
        inst.property2 = 10;
        testService.getCfc( inst );
      }

      private function loadInst():void {
        testService.outCfc();
      }

      private function onFault(event:FaultEvent):void {
        Alert.show(event.fault.message);
      }
      private function onResult(event:ResultEvent):void {
        Alert.show( ObjectUtil.toString( event.result ) );
      }

    ]]&gt;
  </mx:Script>

  <mx:RemoteObject id="testService" source="Service" destination="ColdFusion"
    endpoint="http://localhost:8888/flex2gateway"
    fault="onFault(event);"
    result="onResult(event);" />

  <mx:Button label="Get CFC from Railo" click="loadInst();" />
  <mx:Button label="Send CFC to Railo" click="sendInst();" />

</mx:Application>
[/source]</pre>
<p>with this <em>com.gruchalski.railo.test.TestCFC</em> VO:</p>
<pre>[source lang='as3']
package com.gruchalski.railo.test {

  [RemoteClass(alias="com.gruchalski.railo.test.TestCFC")]
  public class TestCFC {
    public var property1:String = "";
    public var property2:Number = 0;
  }
}
[/source]</pre>
<p>When loading a CFC instance following issue is reported:</p>
<p><q><em>faultCode:Server.Processing faultString:&#8217;An error occurred while serializing server response(s).&#8217; faultDetail:&#8217;null&#8217;</em></q></p>
<p>In case of sending a VO:</p>
<p><q><em>faultCode:Server.Processing faultString:&#8217;flex.messaging.MessageException: railo.runtime.exp.UDFCasterException : invalid call of the function getCfc, first Argument (INST) is of invalid type, can&#8217;t cast Object type [Struct] to a&nbsp;value of type [com.gruchalski.railo.test.TestCFC]&#8216; faultDetail:&#8217;null&#8217;</em></q></p>
<p>First one is obvious, BlazeDS does not know how to serialize CFC provided by Railo. Second issue is probably caused by the fact that Railo does not treat <em>magic structures</em> as CFCs. What I call a <em>magic structure</em> looks like this:</p>
<pre>[source lang='cf']
<cfscript>
  struct = structNew();
  struct.property1 = "Some property";
  struct.property2 = 20;
  struct.__type__ = "com.gruchalski.railo.test.TestCFC";
</cfscript>
[/source]</pre>
<p>When structure like that comes from the outside world or is being sent to outside world (for example BlazeDS iteraction or SOAP request) Adobe ColdFusion treats it as a CFC instance.</p>
<p>Despite the issue I think Railo is a very good choice in its current state. For most small applications current BlazeDS integration level is enough, new applications can easily use what is there right now. And I&nbsp;am sure that Railo team is working hard to enable full support.</p>
<p>It is good however to know the limitations before making the switch to Railo, specially when so many people consider to do so.</p>
]]></content:encoded>
			<wfw:commentRss>http://gruchalski.com/2009/04/20/railo-blazeds-and-cfc-instances/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
