Search Flex Components Free

Custom Search

December 7, 2007

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.


PLAIN TEXT
C#:
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;
}
}
}
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.
PLAIN TEXT
C#:
using System;
using System.Web;

namespace net.shrefler.vo
{
public class EmployeeVO
{
public string firstName;
public string lastName;

public EmployeeVO()
{
}
}
}
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.

Related Flex Tutorials