Flex and. NET Collaborative development tool FLUORINEFX Flex and. NET Interop _flex

Source: Internet
Author: User
Tags cdata documentation

It is very convenient and simple to complete the communication with the server in these ways, but his disadvantage is that the amount of communication data is small, such as to transmit a large amount of data or to achieve the serialization of different objects of transmission, they can not meet our needs, need to find another communication protocol, Another efficient transport protocol to replace the SOAP protocol transmission scheme is the AMF (ActionScript message Format) protocol.

Open Source Project FluorineFX is specifically for the. NET platform and Flex communications provided by the AMF Protocol Communication Gateway, we can easily through the FluorineFX to complete communication with. Net.

FluorineFX official offers download and online documentation for installation packages that can help us effectively exploit FluorineFX.

FLUROINEFX Official website:http://www.fluorinefx.com/

Fluroinefx Download Address:http://www.fluorinefx.com/download.html

Fluroinefx online Documentation:http://www.fluorinefx.com/docs/fluorine/index.html

OK, let's take a look at the. NET and flex configurations that use FLUROINEFX communications. The development environment is selected as follows:

. NET:Microsoft Visual Studio 2008 +. NET Framework 3.5

Flex:adobe Flex Builder CS3 + Flex SDK 3.2

Fluroinefx:FluorineFX v1.0.0.15 (click to download)

One. NET service-side development

Create a solution with Microsoft Visual Studio 2008 and add the Fluroinefx Server library, as shown here:

When the FluorineFX service library is added successfully, the project template will automatically create a sample class and an Echo method for us, as follows:

--> 1NamespaceFlexdotnet.servicelibrary
2{
3///<summary>
4///Fluorine sample service.
5///</summary>
6[Remotingservice ("Fluorine Sample Service")]
7PublicClassSample
8{
9Public  sample ()
10          {
11 &NBSP         }
12 
13           public   string  echo ( String  text)
14          {
15                return   gateway echo:    +  text;
16          
17     &NBSP;&NBSP}
18  }

Then add the FluorineFX Web site to the solution, and the site will automatically reference the DLL for the FluorineFX service library after it is successfully added. The following figure:

Here we can simply test whether the FluorineFX. NET server was created successfully. By viewing the console.aspx in the Fluroinefx Web site in the browser or by setting the Web site to the startup project and setting the Console.aspx Run the site for the start page can, the program will run to the FluorineFX console, expand the left side of the project's Services node will see the template for us to create the class and method, click the method node on the right side can be a simple test, the following diagram:

OK, here we go. NET Server end, we need to remember several points, in the next flex development needs to be based on these parameters to configure.

FluorineFX. NET Web Site Directory:F:\Demo\FlexDotNet\Web

FluorineFX. NET Web Site Virtual directory:/web

FluorineFX. NET Web site URL:http://localhost:2836/Web

URL to accept Flex client request:http://localhost:2836/Web/Gateway.aspx

With these things, it's easy to configure Flex, first create a Flex project, and point the project path to the root path of the previously established FLUORINEFX Web site:

As shown in the figure above, set the application type to: Web application,application Server type is set to:asp.net, and then "Next". Go to the next Create Project Wizard interface and set the server to: "UseInternet information Services (IIS)", and the Web application root also points to the root path of the FluorineFX Web site , the Web appliation URL is set to the path above we get the OK, detailed see the following figure:

Follow the steps above to configure and verify by clicking "Validate Configuration", as the result of the verification is: the Web application root and the URL are valid. This means that the configuration is correct, you can directly point to the next step only to complete the creation of the project.

After the Flex project is created, you can communicate through FluorineFX and. NET with some appropriate configuration. Development Project Properties Setup Panel, set its flex compiler as shown in the following illustration (the-services configuration can also be set to a relative path):

Set flex server to the following configuration, you can point to "Validate Location" Verify the correctness of the settings:

Finally set the output path to complete the flex-side configuration:

Here the flex-side configuration is complete, below we through the FluorineFX Library template for the sample we generated for example to test whether the environment can be passed, under the flex Mxml file through the <mx:RemoteObject> tag to access the remote object, in detail as follows:

--> 1  mx:remoteobject id = " service "  destination = " fluorine "
2      source = FlexDotNet.ServiceLibrary.Sample
3            mx:method name = " Echo "  result = " onresult (event) "
4            </ mx:method
5  </ mx: RemoteObject

Note that the destination needs to be set to match the ID of the destination in Remoting-config.xml, and source is configured as the full path to the remote object (namespace + Class), through <mx:method> The label configures the method under the remote object and sets the result handler function after it is successfully invoked, and the remote method can be invoked by ID.

--> 1<Mx:script>
2<![cdata[
3Import mx.rpc.events.ResultEvent;
4InternalfunctionOnClick ():void
5 {
6Service. Echo (Txtinput.text);
7 }
8
9 Internal function Onresult (evt:resultevent):void
Ten {
One txtresult.text = evt.result.toString ();
The }
] ]>
</mx:script>

The following is the complete code definition for the Flex client mxml:

Complete sample Code
-->1?XML version= "1.0" encoding= "Utf-8"?>
2<Mx:applicationXmlns:mx= "Http://www.adobe.com/2006/mxml"Layout= "Absolute">
3<Mx:remoteobjectId= "Service"Destination= "Fluorine"
4Source= "FlexDotNet.ServiceLibrary.Sample">
5<Mx:methodName= "Echo"Result= "Onresult (event)">
6</Mx:method>
7</Mx:remoteobject>
8
9<Mx:script>
10 <![cdata[
11Import mx.rpc.events.ResultEvent;
12Internal function OnClick (): void
13{
14Service. Echo (Txtinput.text);
15}
16
17Internal function Onresult (evt:resultevent): void
18{
19Txtresult.text = Evt.result.toString ();
20}
21st]]>
22</Mx:script>
23
24<Mx:panelX= "53"Y= "52"Width= "250"Height= "200"Layout= "Absolute"Title= "Test FluorineFX"FontSize= "12">
25<Mx:textinputX= "35"Y= "21"Id= "Txtinput"/>
26<Mx:buttonX= "35"Y= "63"Label= "OK"  fontweight = "normal"  click = "OnClick ()" />
27           ; mx:label  x = "a"  y = ""  text = "knot   fruit:" />
28            mx:textinput  x = "A"  y = " 123 "  width =" 160 "  id =" Txtresult "/>
29       </ mx:panel
30  </ mx: Application
31 

This article example screenshot:
     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.