<?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>CarbonRider &#187; Flex issues</title>
	<atom:link href="http://www.carbonrider.com/tag/flex-issues/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.carbonrider.com</link>
	<description>You make a matrix, you define the limits.</description>
	<lastBuildDate>Thu, 19 Jan 2012 04:35:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Flex Goofups</title>
		<link>http://flex.carbonrider.com/2009/08/14/flex-goofups/</link>
		<comments>http://flex.carbonrider.com/2009/08/14/flex-goofups/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 05:05:30 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex and Webservices]]></category>
		<category><![CDATA[Flex issues]]></category>
		<category><![CDATA[Flex soap exception]]></category>
		<category><![CDATA[Remote Object]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=26</guid>
		<description><![CDATA[ WELCOME – Flex Issues  Background Bored of creating prototypes in HTML or using any other tool, Flex is the ultimate tool. It has been a long time, Flex has been dominating RIA world with its strong features and easy to use development environment. Flex provides very strong development environment which can be used to develop [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2009%2F08%2F14%2Fflex-goofups%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2009%2F08%2F14%2Fflex-goofups%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div>
<h2> <strong>WELCOME – Flex Issues</strong></h2>
</div>
<p><strong> Background</strong><br />
Bored of creating prototypes in HTML or using any other tool, Flex is the ultimate tool. It has been a long time, Flex has been dominating RIA world with its strong features and easy to use development environment. Flex provides very strong development environment which can be used to develop Rich Internet application with stunning effect and that too within minimal time. Though same effects can be achieved in Adobe® Flash®, the time and ease provided by Flex comes to the rescue of developer to build something in less time.<br />
While Flex™ is considered to be the best tool amongst all other RIA technologies, there are some areas where Flex has not shown maturity or simply fails to perform. In this article I will walkthrough few of those issues which Flex cannot tackle on its own.</p>
<p><span id="more-26"></span></p>
<p> <strong>FLEX PITFALLS</strong><br />
This section lists various areas where Flex fails to perform and finding out solutions to those problems can result into worst nightmare for developer. This article attempts to list solutions for various Flex issues.<br />
<strong>Webservice Integration</strong><br />
While Flex has been considered a perfect choice for implementing Rich UI, it is not recommended to put your business logic inside Client technologies. This would not only make your UI big in file size but will also expose business functionality to end users. Hence a smart developer will always try to create User Interface with minimal or no business logic in it.<br />
Most of the time business logic will be implemented using various server side technologies like JEE, .Net, PHP, Ruby etc. and will be exposed as webservices. (Note you are not limited to expose server side logic using only webservices, Flex provides various options to access server side logic.)<br />
Let’s consider that you have implemented a webservice which returns Profile information for the given User ID. The webservice request structure might look like following.</p>
<pre class="brush: xml;">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:mys="http://www.myservice.com/MyService">
   <soapenv:Header/>
   <soapenv:Body>
      <mys:getProfileForUser>
         <UserID>jimmy</UserID>
      </mys:getProfileForUser>
   </soapenv:Body>
</soapenv:Envelope>
</pre>
<p> And response from Webservice might look like this.</p>
<pre class="brush: xml;">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getProfileForUserResponse xmlns:ns2="http://www.myservice.com/MyService">
         <return>
            <ns2:firstName>Jimmy</ns2:firstName>
            <ns2:lastName>Carey</ns2:lastName>
            <ns2:age>25</ns2:age>
            <ns2:addressLine1>ABC House</ns2:addressLine1>
            <ns2:addressLine2>M J Road</ns2:addressLine2>
            <ns2:postalCode>14219</ns2:postalCode>
            <ns2:country>USA</ns2:country>
         </return>
      </ns2:getProfileForUserResponse>
   </soap:Body>
</soap:Envelope>
</pre>
<p>The most easiest way to access webservice in Flex is making use of &lt;mx:Webservice&gt; tag. So let’s have a look at the Flex application runtime and see how data is presented in Flex application.</p>
<div>
<dl id="attachment_8" style="width: 460px;"><img title="Flex At Runtime" src="http://www.carbonrider.com/wp-content/uploads/2009/08/flex_at_runtime.JPG" alt="Flex At Runtime" width="450" height="444" /> Flex At Runtime</dl>
</div>
<p> (Note the Flash file application is accessed using <a href="http://localhost:8080/">http://localhost:8080/</a>&#8230;. To access webservice the flex application must be running on Webserver/Application Server. Also due to Flash Player plugin restriction, Flash applications can only access resources from the domain they are downloaded or otherwise the remote domain must contain crossdomain.xml at the root location.)</p>
<p>So far so good, Flex displays all the information retrieved from Webservice. Now let’s add some twist to webservice response. Assume that there is no data available for “AddressLine2”, which appears after “AddressLine1” and before “ProfileCode”. So the webservice response may look like following</p>
<pre class="brush: xml;">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getProfileForUserResponse xmlns:ns2="http://www.myservice.com/MyService">
         <return>
            <ns2:firstName>Jimmy</ns2:firstName>
            <ns2:lastName>Carey</ns2:lastName>
            <ns2:age>25</ns2:age>
            <ns2:addressLine1>ABC House</ns2:addressLine1>
            <ns2:postalCode>14219</ns2:postalCode>
            <ns2:country>USA</ns2:country>
         </return>
      </ns2:getProfileForUserResponse>
   </soap:Body>
</soap:Envelope>
</pre>
<p>(Notice addressLine2 tag is missing from Webservice response, since there is no data available for addressLine2.)</p>
<p>Reload Flex application in browser and Voila</p>
<div>
<dl id="attachment_10" style="width: 513px;"><img title="(What went wrong with Flex, why it is not displaying “Postal Code” and “Country”.)" src="http://www.carbonrider.com/wp-content/uploads/2009/08/flex_sample_profilepage.jpg" alt="flex_sample_profilepage" width="503" height="447" /> (What went wrong with Flex, why it is not displaying “Postal Code” and “Country”.)</dl>
</div>
<p> Did you notice, though PostalCode and Country is having values, Flex has simply discarded those values and refused to display anything which comes after “Address Line 1”. After crawling through Adobe Bug repository, I found following justification from Adobe.<br />
<a href="https://bugs.adobe.com/jira/browse/SDK-14194">https://bugs.adobe.com/jira/browse/SDK-14194</a><br />
<a href="http://www.activeguru.co.uk/posts/why-flex-3-might-kill-your-web-services-powered-application/">http://www.activeguru.co.uk/posts/why-flex-3-might-kill-your-web-services-powered-application/</a><br />
(Check what “Svetlin Kalaydjiev &#8211; [01/10/08 02:35 PM ]” says in response to bug. The most interesting stuff is that, this bug was not present in Flex 2 and Flex application used to process webservice request as expected. But Adobe has made modifications to Flex 3 SDK and all the existing applications using webservices are facing issues with new SDK.)</p>
<p><strong>Ways to overcome<br />
</strong>1. This issue generally occurs with value objects generated using JAXB due to the strict validation enforced by the framework. If you are using JAXB to generate value objects from XSD. Make sure that you add nillable=”true” to the elements which may possible contain null values.<br />
2. You won’t face this issue with handcrafted value objects not using JAXB annotations.<br />
3. Make use of “&lt;mx:RemoteObject&gt;” instead of “&lt;mx:Webservice&gt;” and make make use of SPRING-BlazeDS integration framework to call webservices. (This is the best way of accessing webservices or server side business logic. Using this approach you can even access webservices or URLs hosted on remote servers and that too without need of having crossdomain.xml file at remote servers. There are many more advantages of this approach but this article would not suffice for explanation.)</p>
<p><strong>SOAP Exception</strong><br />
One of the worst nightmares we had is capturing Exception raised at server-side by webservices. Check following screenshot of Flex application when exception is raised.</p>
<div>
<dl id="attachment_9" style="width: 307px;"><img title="(Note there is fault handler added in Flex code, which displays exception message.)" src="http://www.carbonrider.com/wp-content/uploads/2009/08/flex_http_request_error.jpg" alt="flex_http_request_error" width="297" height="161" /> (Note there is fault handler added in Flex code, which displays exception message.)</dl>
</div>
<p>While here is the actual exception message raised at server side.</p>
<pre class="brush: xml;">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Sorry, Profile information cannot be retrieved at this time.</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
</pre>
<p>The fact lies with the Browser and not Flash Player Plugin. Checkout following URLs<br />
<a href="https://bugs.adobe.com/jira/browse/SDK-11841">https://bugs.adobe.com/jira/browse/SDK-11841</a><br />
<a href="http://bugs.adobe.com/jira/browse/SDK-19956;jsessionid=968D6E0B7B5EBF52E57361A012BC3D0D">http://bugs.adobe.com/jira/browse/SDK-19956;jsessionid=968D6E0B7B5EBF52E57361A012BC3D0D</a><br />
Every request sent from Flash Player Plugin to Server will be intercepted by Browsers and if the response header is other than 200, browser will not make actual exception message available to Flash Plugin.</p>
<p><strong>Ways to Overcome<br />
</strong>1. Mould your web framework and always force it to generate HTTP response code as 200.<br />
2. Implement Filter (JEE) and modify HTTP response code as 200.<br />
3. Make use of BlazeDS framework. Using this approach requires integration of Adobe BlazeDS framework with Flex Application. Also &lt;mx:Webservice&gt; tag will no longer contain wsdlUrl attribute. Webservice URL settings should be specified in proxy-config.xml and &lt;mx:Webservice&gt; tag must contain “destination” tag to call appropriate webservice.</p>
<div>
<dl id="attachment_12" style="width: 513px;"><img title="(By using BlazeDS, Flash Plugin is able to access appropriate error message. For more details about Flex and BlazeDS integration visit following URL)" src="http://www.carbonrider.com/wp-content/uploads/2009/08/soap_error_with_blazeds.jpg" alt="soap_error_with_blazeds" width="503" height="179" /> (By using BlazeDS, Flash Plugin is able to access appropriate error message. For more details about Flex and BlazeDS integration visit following URL)</dl>
</div>
<p><a href="http://opensource.adobe.com/svn/opensource/blazeds/trunk/apps/samples/fb-project-setup.htm">http://opensource.adobe.com/svn/opensource/blazeds/trunk/apps/samples/fb-project-setup.htm</a></p>
<p><strong>WS-Security<br />
</strong>While Flex provides “&lt;mx:Webservice&gt;” tag to access webservices, it doesn’t provide any API to implement WS-Security features (WS-UsernameToken, X.509 implementation etc). Hence if you are accessing any webservice which requires client to adhere to above specification then Flex simply fails to meet the expectations.<br />
Ways to Overcome<br />
1. You can find Google code contribution at following URL which will provide implementation for WS-UsernameToken implementation, But till now I haven’t found any library which can help you to implement X.509 implementation<br />
<a href="http://code.google.com/p/as3corelib/">http://code.google.com/p/as3corelib/</a><br />
2. Make use of SPRING-BlazeDS integration framework and do not invoke webservices directly from Flex. Let server side code implemented using above integration framework to call webservices so that you can now have an option to implement all the WS-* compliant client. Though a communication between WebService consumer and Webservice Producer will be encrypted using this approach, the data transmitted between Flex application and Webservice consumer code would still be vulnerable. Hence such communication must be protected using appropriate mechanism.</p>
<p><strong>Undetermined Behaviour</strong><br />
Using renderers/editors in AdvancedDataGrid has been a real pain. When heavy data is loaded into Advanced Data Grid with Hierarchical Structure and if such Grid is scrolled vertically, sometimes the position of data changes. For example values displayed in 4th row are displayed in 6th row and so on.</p>
<p><strong>Memory Hogging</strong><br />
Though Flex is packed with various features that will give you WOW feedback from your customers and end users, your application will have major setback due to Memory Leakage problems in Flex developed application. After constant monitoring of application and user activities it has been noticed that Flex Player and thereby browsers keeps on consuming memory though same screens are visited. If Browser continues to eat up memory, you will notice that after some time the screen will go blank or browser will close unexpectedly.<br />
Adobe recommends various alternatives to overcome Memory Hogging issue and they are as follows<br />
• Using ModuleLoader to load various parts of application.<br />
• Using SWFLoader<br />
• Using ModuleLoader with new ApplicationDomain<br />
Unfortunately none of the approach provides expected results. The interesting stuff is that, if you are viewing Flex application in Internet Explorer, minimize the browser window and wallah… You will find that the memory consumed by browser has drastically come down. This won’t happen with other browsers.</p>
<p><strong>CONCLUSION</strong><br />
Though some of the issues listed here may not be severe for application in small size, it would really hamper user experience and development for large scale applications. Hence while selecting Flex as preferred tool for User Interface development make sure you understand all the above listed issues. If you have any specific issue with Flex and want to report it to Adobe® use following URL.<br />
<a href="http://bugs.adobe.com/">http://bugs.adobe.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2009/08/14/flex-goofups/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

