Invoking RESTful and AMF services from Flex using WCF / MVC / FluorineFX in .NET

Posted by admin on November 12th, 2011

icon ria Invoking RESTful and AMF services from Flex using WCF / MVC / FluorineFX in .NETI’ve written a small Rich Internet Application using Flex and [dot]NET. Data from [dot]NET is returned to Flex using different technologies being MVC, WCF and FluorineFX.

In dot[NET], there are two MVC controllers, RestJsonController and RestXmlController. They both have about the same logic, but one returns Json, the other XML. There’s also a UserService with methods made public using both WCF and FluorineFX. For WCF, REST is used with both GET (WebGet) and POST(WebInvoke).

On the Flex side, REST calls are being done using URLLoader and URLRequest.  There are examples using GET and examples using POST. You’ll also see that URLVariables, Json strings or XML are used to transport data. For the AMF calls, a RemoteObject is used to call a FluorineFx gateway.

Flex only supports the HTTP Verbs GET and POST, so full REST isn’t really possible.

I created the example in Visual Studio 2010 (ASP.NET MVC 3 Web Application) and Flash Builder 4.5 Premium (SDK Version 4.5.1). You can easily open the .NET solution. The Flex source is configured to call localhost on port 53259, so make sure the .NET WebApp is started on that port (or change the Flex source code). For the Flex project, import it using ‘Existing Projects into Workspace’. Since Flash Builder has a problem with relative paths (adobe, please have a look at that), you’ll have to change some things. In the properties of the project, go to Flex Build Path, and set the Output folder to [root example project]/FlexDotNetREST/Flex, being the Flex folder under the root of the .NET Web App. Then right click FlexRest.mxml –> Run As –> Run Configurations… URL or path to launch should be http://localhost:53259/Flex/FlexRest.html.

A zip of the example can be downloaded here.

As I wife recently gave birth to a second daughter, I haven’t got the time anymore to blog a lot. So, explaining this will be difficult. But you have the source and I’ve written a lot of comment in the source it self. So check it out and let me know if it was useful.

Be sure to go and read some articles and blog posts on REST, especially the difference between low REST and high REST (lo-REST – hi-REST). A lot of developers/managers/companies think they have a RESTful api, but actually, they don’t.

http://blog.jonnay.net/archives/665-Hi-Rest-and-Lo-Rest,-two-broken-halves-of-the-tower-of-Babylon.html
http://lesscode.org/2006/03/19/high-low-rest/

WCF REST
REST in Windows Communication Foundation (WCF)
A Developer’s Introduction to Windows Communication Foundation 4

Read the rest of this entry »

Problem Event Handlers in a Default Document in IIS 7 or IIS 7.5 Integrated Mode with FluorineFX Http Module

Posted by admin on September 10th, 2011

images Problem Event Handlers in a Default Document in IIS 7 or IIS 7.5 Integrated Mode with FluorineFX Http Moduleicon asp.net  Problem Event Handlers in a Default Document in IIS 7 or IIS 7.5 Integrated Mode with FluorineFX Http ModuleSome while ago I noticed that an OnClick isn’t triggered when a default aspx page is loaded (for instance browsing to http://localhost/test) but it is when browsing directly to http://localhost/test/default.aspx. The default document is set to Default.aspx, but for some reason, the click event isn’t triggered when doing a Postback.

Read the rest of this entry »

Forcing browsers to revalidate static content in IIS – Asp.NET

Posted by admin on September 3rd, 2011

icon WebCache 150x150 Forcing browsers to revalidate static content in IIS   Asp.NETHow do you force browsers to revalidate static content like an swf, xml, txt, … files? We often have this problem with customers and advise them to clear their cache. Not a very good solution don’t you think?

So how do you solve this? We could append the version of our product to the static files, so that with a new release, browsers wouldn’t hit their cache loading the file. A condition for this to work would be that the home page (default page) should always be the latest version from the server. This page would have references to the static files with version appended to them.

What about browsers asking the server if a newer version is available. In comes the must-revalidate header.

Read the rest of this entry »

pixel Forcing browsers to revalidate static content in IIS   Asp.NET

Copyright © 2007 Lieven Cardoen. All rights reserved.