Adobe Flex 2.0 + Cairngorm + Fluorine + ASP.NET Sample Application / Tutorial
After my last tutorial/post about using WebOrb, I began using Fluorine. Recently a request was made for a tutorial, so here goes…
Using Service Capture , an ABSOLUTELY fantastic tool and Fluorine with AMF3, still seems to be a problem. Also, I wanted to try and use the RemoteObject tag with my solution to make using .NET a little less coupled. Well, it turns out; Fluorine still seems to work great with AMF0, the remoting format from Flash 8. This led me to Renaun’s RemoteObjectAMF0 which easily plugs into a Cairngorm ServiceLocator. So there’s the pieces, now to put together the puzzle.
Renauns’s RemoteObject also works with AMF3. The reason I’ve been using AMF0 is that AMF3 + Fluorine doesn’t seem to display correctly in Service Capture. Possibly after I’m done developing my current project, I’ll switch this to AMF3 and see if any problems occur. You simply need to change the the line in RemotingConnection.as:
objectEncoding = ObjectEncoding.AMF0;
to:
objectEncoding = ObjectEncoding.AMF3;
First you will need the following for this tutorial: Visual Studio 2005, Adobe Flex Builder 2.0, Renaun’s RemoteObjectAMF0 (link), and Cairngorm (link), and Fluorine.
Open Visual Studio and Create a New Web Service: File -> New -> Website -> Empty Web Site.
Create a new C# Class: File -> New -> File -> Class -> Name the class EmployeeService.cs. You may be prompted about placing the cs file in the App_Code Folder, choose Yes.
A file EmployeeService.cs will be created in the App_Code Folder. Open EmployeeService.cs. Enter the following code.
[csharp]
using System;
using System.Web;
using net.shrefler.vo;
namespace net.shrefler.service
{
public class EmployeeService
{
public EmployeeService()
{
}
public EmployeeVO[] getEmployees()
{
EmployeeVO[] emps = new EmployeeVO[2];
EmployeeVO emp = new EmployeeVO();
emp.firstName = “Sam”;
emp.lastName = “Shrefler”;
emps[0] = emp;
emp = new EmployeeVO();
emp.firstName = “Your”;
emp.lastName = “Name”;
emps[1] = emp;
return emps;
}
}
}
[/csharp]
Create a new C# Class: File -> New -> File -> Class -> Name the class EmployeeVO.cs. You may be prompted about placing the cs file in the App_Code Folder, choose Yes.
A file EmployeeVO.cs will be created in the App_Code Folder. Open EmployeeVO.cs. Enter the following code.
[csharp]
using System;
using System.Web;
namespace net.shrefler.vo
{
public class EmployeeVO
{
public string firstName;
public string lastName;
public EmployeeVO()
{
}
}
}
[/csharp]
Next we’ll need to add Fluorine to our application. Add a “Bin” Folder to your Web Site. Right-Click on Bin and go to “Add Existing Item.” Browse to where you downloaded Fluorine and add “com.TheSilentGroup.Fluorine.dll”. Right click the root folder of your website and go “Add Reference”. Click the Browse tab, and add the “com.TheSilentGroup.Fluorine.dll” in your Bin folder.
Open web.config and add the following code.
[xml]
[/xml]
Next, create an empty Gateway.aspx file in the root of your website.
Finally, Rather than describing all the flex code: I decided to just use the Source View. So here is the flex code: (link)
I hope this helps everyone as much as I hope it will help me. As always, comments are appreciated. Good Luck!

Hey Sam, nice concise article. Which part, if any, requires VS 2005? I am not a .NET guy myself but I work alongside several. Would like to throw together something simple like this but we’re still using VS 2003.
Thanks,
Ben
Ben:
Thank you. The only reason for needing VS 2005 is to be able to follow my instructions word for word. As long as your developer can follow along, make the services, and add the Fluorine.dll reference in .NET, there shouldn’t be any problem.
If you need any additional help, let me know.
Sam
Thanks for the tutorial Sam! I made some excellent advancements in my understanding on how all these pices are going to fit together: flex, .net, fluorine, and implemention of cairngorm. Your tutorials gave me direction.
Did some major reading on cairngorm these past two days, and I recomend others to do so too; If only to get ideas of best practice client side architecture.
I now have a general solid structure of how tol implement a flash front end on a .Net backend.
Sam, have you tried charles http debugging proxy? I haven’t tried it with AS3, but its the same deal as service capture and the author does say it support the new AMF so maybe it can be used?
thanks for the tutorial, I had a heartattack when I saw the cost of FDS and use flourine right now with .net and flash8/7 so this tut should help a lot.
Ok, soo, I’m getting casing errors when sending VO’s with an “int” value.
int(C#) = Number(Actionscript)
hmmmm…
somthing must be done to the int value within the vo on the server side… any ideas?
Define a service in the service-locator for each delegate!!!
I ran into problem when addingEventListener to the service defined in the service-locator in one delegate-object that was used by another delegate-object.
To make a long story short, whenever I used the service two delegates triggered and thus two commands triggered causing the model to fukk up..
So just give a seperate service name for each delegate; that’s how I solved it… I would like to hear of anyone that has a better idea…
for some reason, I cannot get this to work; it throws “call failed” error. Is there a way to test that my web service is setup appropriately?
How does the magical blank Gateway.aspx file work?
What am I supposed to see if I load that url in IE? I get “cannot connect to webpage”.
Nevermind. I changed ‘localhost’ to my machine name, and it works fine. Odd.
also, amf3 is working fine with servicecapture for me.
Hi. Thanks for the tutorial. I have it running ok under IIS and under apache, but I have a problem I cant solve. When it’s running on apache, only Internet Explorer see data on the datagrid, firefox dont work, but runing on IIS firefox display all ok. Have tried different configs for apache with no luck.
Thanks for all
[...] In order to update my projects (As created from my this post), I’ve followed the following steps and everything seems to work great. [...]
Could you please post a Zip of all of your source for the Web Service and the Flex side?
I get an error that I cannot find the service… So I must be mising something, any help would be appreciated.
Mark:
Please ask any questions you have on getting Fluorine working on the fluorine mailing list…that way others will also learn from what you are doing.
Thanks
Sam
Sam, I was wondering if Flex Data Services is required to complete this tutorial or to use Flex 2, Cairngorm, Fluorine, and ASP.NET?
Mark:
No sir. All of this can be done with the standard SDK.
Sam
For those of you who dont want just the basics, there is another excellent tutorial at
http://www.darbymedia.com/blog/?p=389
Any idea on how to make setCredentials work?
I have tried so with instructions on this page but I can’t seem to make it work…
Allways get an error saying ILoginCommand is not found…
Where is web.config? That isn’t specified at all, and a search results in 50 web.config files on my system…
Never mind. Between
“Click the Browse tab, and add the “com.TheSilentGroup.Fluorine.dll” in your Bin folder.”
and
“Open web.config and add the following code.”
There’s no mention that one should build the CS project.
Sir,
I m using Flex 3.0 Beta Bulider. I want to access .NET Objects without using Third party tool. If Possible,Please tell me about config -files.any steps reuired please tell me.
Thanks in Advance
Harikrishna
Hi Sam,
I have a sql server 2005 database, and want to create a flex 3 website that connects to my db, could you give me some pointers as to what I need to do to achieve this.
Cheers
Jonathan
Mark:
Please ask any questions you have on getting Fluorine working on the fluorine mailing list…that way others will also learn from what you are doing.
Thanks
Sam
Thanks
I have two class file which is not placed in the App_Code Folder now i want to access a method from one class to another is that possible??????
Here in the tutorial you are writing: ——
“Right-Click on Bin and go to “Add Existing Item.” Browse to where you downloaded Fluorine and add “com.TheSilentGroup.Fluorine.dll”.
—–
Great. The only problem is there is no com.TheSilentGroup.Fluorine.dll in the downloaded Fluorine package. Scanning whole hard drive after downloading and installing Fluorine did not help too. How can I proceed without such dll and why all of a sudden it is not in the distribution any more?
Nice read thanks for the snippets. This will work well with the ones I found over at aspdotnetatoms.com
Sir, Please guide me on using Flex and .Net by providing some resources
Hello..
I am new with Flex, and i am wondering if i could call DLL from flex without the technologies of weborb or flourine.. is that possible?
Pls, help me..thanks