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 »

Using Zinc with Flash9/Flex AS3 Swf’s

Posted by admin on December 20th, 2007

I had a Zinc project which worked fine on PC but showed absolutely nothing on Mac. I just got a nice Window with nothing in it. Even a swf with a simple button wouldn’t load on Mac.

After an hour of searching I saw that in a Mac Zinc Project, you can choose the Embedded Flash Control in the Flash Settings tab. If you want your executable to work on Mac, you better set this on Flash 9…

 Using Zinc with Flash9/Flex AS3 Swfs

Yeah, life can be hard.

Adobe Air Small Example

Posted by admin on November 27th, 2007

At work I created a small example of Adobe Air with some features in it like:

  1. Save some xml to file
  2. Read some xml
  3. Delete file
  4. Save ScreenShot
  5. Browse Directory
  6. Create Directory
  7. Using the encrypted local store
  8. Dragging a text file into application

It isn’t much and for advanced users it won’t be new, but if you’re just starting with Adobe Air, it can be of some use.

Air Package

Project Zip

Copying folders on Mac & Pc With MDM Zinc

Posted by admin on November 26th, 2007

Copying folders with the function copyFolder from MDM Zinc doesn’t show the same behavior on Mac as it does on PC.

On PC the content of the folder is also copied, on Mac this isn’t the case. On mac only the folder itself is copied, but not the contents. It’s rather annoying as you would expect the same behavior be programmed by MDM.

If you want the same behavior on Mac then you better use some AppleScript.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var shellScript:String = "tell application \"Finder\" \r" + 
    "duplicate \"" + copyFrom + "\" to \"" + copyTo + "\" \r" + 
    "end tell";
trace("EVAFRAMEWORK :: ZincSystemService.as : Executing shellScript : " + shellScript);
 
mdm.AppleScript.setScript(shellScript);
if(mdm.AppleScript.compileScript())
{
    trace("EVAFRAMEWORK :: ZincSystemService.as : Script Compiled Successfully");
    if(mdm.AppleScript.run())
    {
        trace("EVAFRAMEWORK :: ZincSystemService.as : Script Runned Successfully");
    }
    else
    {
        trace("EVAFRAMEWORK :: ZincSystemService.as : Run Error : " + mdm.AppleScript.getLastError());
    }
}
else
{
    trace("EVAFRAMEWORK :: ZincSystemService.as : Compile Error : " + mdm.AppleScript.getLastError());
}

To move a folder, there’s no function available in Zinc, so you need to copy and delete. The function deleteFolder from Zinc does have the same behavior on Mac and PC.

Evolution Desktop Applications – My Experience Part I

Posted by admin on November 19th, 2007

When I began working in the multimedia business, Director was the tool to package swf’s into executables for PC or MAC and having access to the operating system. I never had much experience with Director, only just enough to do the necessary things. Although lots of Director users will probably disagree with me, I think the language lingo was a disaster to use. But Director did the job to open files, write to files, changing resolution, opening internet pages,… I did however get more and more frustrated by Director. It had almost no support, macromedia had stopped development on Director and I did get lots of bugs from customers. Those bugs were reported to Macromedia, but never solved. For me, if you developed everything in Flash, having to use Director to save a few files was too much work, too much problems…

So came Zinc from MDM. There were other alternatives, but none of them supported Mac. Maybe that there are better tools out there than Zinc for PC, but in my experience there are none for PC and Mac. If you worked with Director, Zinc was a fresh breath of air icon smile Evolution Desktop Applications   My Experience Part I but the future would learn that crappy and buggy had been replaced by a bit less crappy and buggy. We have made lots of succesfull applications with Zinc, and development was easier than with Director, but still there were allways bugs. The support of MDM was rather good in my experience, and you would allways get a quick reply. However, lots of bugs were never solved. Lots of times, when a new build came out, an bug was solved, but something else that had allways worked now didn’t anymore. Things like that were very frustrating. Sometimes we had to install a previous version of Zinc to make things work. It’s true that Zinc has hundreds of functions which you can choose, but I would prefer less functions but more reliable. Anway, I still think they did a good job, creating something that has to work on all those crappy windows version and on mac doesn’t seem easy. The thing that frustrated me most is that until today MDM Zinc has no support for standalone cross database… On the PC side you could use Access db connection, but simultaenously connections on an Access db are limited. On mac no database was supported. So for a few projects we still used Zinc on PC, but Director with V12 database on Mac. This makes creating an applications for Pc and Mac expensive. On the other side, functions that are crossplatform (like copying a folder) do not show the same behavior on Pc as on Mac, so you still need to write seperate code for Pc and Mac. The last downside is that you first had to create the swf, and then wrap it into an exe with Zinc. Debugging isn’t easy once you started your exe… Currently MDM states that it is working on a new product called Pandora. There was going to be news at first in May, then in September, but we are now November and still no news. At the forum of MDM things are rather heating up, certainly now that Adobe has released Air. Off course it’s more easy for Adobe to develop things for there own product. Criticizing Zinc is easy, but I’m still thankfull that I can use it. With Adobe Air they have an important concurrent, so I hope this will raise the quality of Desktop Application Tools.

Adobe Air : Until now we are still developing with Zinc, but we have done some studies of Adobe Air, and I must say it looks great. Adobe Air needs a runtime, Zinc doesn’t, so Zinc has an advantage there. But once the runtime is installed, Adobe Air looks a far greater tool than Zinc. First development is fantastic because you can use the same tool to create packages, debugging is f***ing easy and you have code completion for all of the Adobe Air SDK (Zinc has done someting to support some code completion in FlexBuilder, but it’s not the same). Second there’s a support of SQLite, a cross-platform database (hell yeah!). But I’m carefull, and future will tell if Adobe Air is a better tool to create Desktop Applications.

Silverlight : I have seen some examples on conferences. Fantastic would be to have a tool as Visual Studio to develop Desktop Appliations. I’m following it, hoping to play with it in near future. I’ve heard that Mac would be supported, but I would like to see that… Adobe states often that there Flash Player is installed on 95% of pc’s, but Microsoft only has to do a security update, and there runtime would be installed on a lot of pc’s too… With FlexBuilder3 & Adobe Air, one has a tool to create Desktop Applications and debug them easily. But if I had Visual Studio to create Desktop Applications… But it’s hard to talk about something one doesn’t know, and hard to trust Microsoft if you ask me.

Other tools that I now of : NorthCode

 To be continued…

pixel Evolution Desktop Applications   My Experience Part I

Copyright © 2007 Lieven Cardoen. All rights reserved.