Setting
up a
FluorineFX Service
in
Visual Web
Developer 2008 Express
by John Middendorf http://www.Lynxgeos.com
1. Create New Project: select "FluorineFX Service Library" template
--type in a name for a new folder to be placed on Desktop.
--uncheck "Create directory for solution"
2a. Add the following references: (Project>Add Reference-->.NET tab:)
System
System.Data
System.Xml
2b. Also add the Fluorine reference: (Project>Add Reference-->Browse tab):
Browse to Programs>FluorineFx>Bin>net>3.5>FluorineFX.dll
(Note the "Imports FluorineFX" statement in Sample.vb.)
3a.Add New Website--Select "FluorineFX ASP.NET Web Site"
3b. Browse to the same folder that you created in step 1 for the ServiceLibrary
(note: you can use Visual Basic or C#--your choice!)
3c. Alert pops up--Select "Create a new Web site in the existing location"
3d. Message pops up "Search Path for Assemblies Not Found" --just click ok.
4.Take note of your directory structure...
...which corresponds to your folder structure:
5a. Set your Web Site up as the StartUp Project
5b. And your Console.aspx as the Start Page:
6. Add a reference to the console Service Browser to the Web Page so you can debug effectively (optional). This .dll is located as above, in Programs> FluorineFX>Bin>net>3.5 . NOTE: you should remove this .dll for the production version.
7. Run your project. Remember to turn off debugging for
production version:
8.. Drill down the tree on the left, and select a service. Test your first FluorineFX call!
NEXT STEPS:
--Add new functions that return data in the ServiceLibrary1 Sample.vb (or Sample.cs) file.
--Publish to a ASP.NET server,
now you can
call your Service remotely in Flex.
The Flex application can be hosted on a remote computer from
this
Fluorine Service. In most
respects, FluorineFX functions like a Web Service, yet much faster for
larger data
sets.
Download ASP.NET source code at http://www.deuce4.net/web/fluorine/FluorineAMF.zip
FLEX CODE: Note again that the Flex application can be hosted on
separate computer as the ASP.Net code.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()">
<mx:Canvas width="400" height="300" x="100" y="100">
<mx:VBox width="400" height="300" verticalCenter="0"
horizontalCenter="0">
<mx:Text text="Enter Text to Echo with Fluorine:" width="198" />
<mx:TextInput id="txtInput" width="198"/>
<mx:Button label="Call Fluorine Service" click="fluorineSend()"/>
<mx:Label id="lblEcho" text="Echo Text Here" width="379" height="35"
fontWeight="bold" fontSize="17" textAlign="left"/>
<mx:Label id="lblTimer"/>
</mx:VBox>
</mx:Canvas>
<mx:RemoteObject id="ro" destination="fluorine"
source="ServiceLibrary1.SampleService"
fault="onFluorineFault(event)">
<mx:method name="Echo" result="onFluorineResult(event)" />
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
public var startTime:Number;
//set up the AMF channel:
//this eliminates the need to reference any config files--yay!
public function init():void{
var amfChannel:AMFChannel = new AMFChannel("myAMF",
"http:// PutYourUrlHere /FluorineTest/Gateway.aspx");
amfChannel.pollingEnabled = false;
var myChannelSet:ChannelSet = new ChannelSet();
myChannelSet.addChannel(amfChannel);
ro.channelSet = myChannelSet;
//ro.requestTimeout=20;
}
//SEND FUNCTION (when button is pressed):
public function fluorineSend():void{
lblTimer.text="";
startTime = new Date().time;
ro.Echo(txtInput.text);
}
//RESULT FUNCTION
public function onFluorineResult(event:ResultEvent):void{
lblTimer.text = "The Process took " + (new Date().time - startTime) + "
ms";
lblEcho.text=event.result.toString();
}
//FAULT FUNCTION
public function onFluorineFault(event:FaultEvent):void{
Alert.show("Fluorine Fault", event.fault.toString());
}
]]>
</mx:Script>
</mx:Application>
Comments? Corrections? Post them on the FluorineFX Forum at
http://forum.fluorinefx.com/viewtopic.php?f=7&t=187
[Written by John Middendorf (c)November 2008 http://www.LynxGeos.com]