SoFunction
Updated on 2025-04-08

Flex and .NET Interoperability Understand the environment configuration of FluorineFx (remote objects, gateways, channels, destinations)

The method of accessing Webservice introduced in the previous articles in this series is a remote object method. It is just that it is a remote access based on the WEB service (WebServie), not a remote access based on the Remoting Object. It is quite troublesome to directly implement object-based remote access. FluorineFx specifically provides us with this function, and develop remote object (Remoting Object) services through the core library of FluorineFx. How is it implemented specifically?

FluorineFx requires the remote object to provide the [RemotingService] tag to provide remote object services. Check out the detailed definition of RemotingServiceAttribute below:

1 [AttributeUsage(, AllowMultiple = false)]
2 public sealed class RemotingServiceAttribute : Attribute
3 {
4     public RemotingServiceAttribute();
5     public RemotingServiceAttribute(string serviceName);
6 }


From the sample code in the previous article, we can see that a remote object service class of Sample is defined using .NET (c#) and [RemotingService] is specified as follows:

 1     [RemotingService("Fluorine sample service")]
 2     public class Sample
 3     {
 4         public Sample()
 5         {
 6         }
 7 
 8         public string Echo(string text)
 9         {
10             return "Gateway echo: " + text;
11         }
12     }

From the previous article, an example of remote objects called FluorineFx by Flex client has appeared in the process of building FluorineFx development environments. Let's take a look at this example below:

1     <mx:RemoteObject id="service" destination="fluorine"
2         source="">
3             <mx:method name="Echo" result="onResult(event)">
4             </mx:method>
5     </mx:RemoteObject>
 1     <mx:Script>
 2         <![CDATA[
 3             import ;
 4             internal function onClick():void
 5             {
 6                 ();
 7             }
 8             
 9             internal function onResult(evt:ResultEvent):void
10             {
11                  = ();
12             }
13         ]]>
14     </mx:Script>

As mentioned above, remote object access can be realized, and remote object connection can be made through Flex's non-visual component <mx:RemoteObject>. The source attribute specifies the remote object, and the format is a fully qualified name (namespace + class name). The destination attribute is very important, which determines whether the Flex client can correctly access the remote object. The relevant configuration is as follows:

1     <destination id="fluorine">
2         <properties>
3             <source>*</source>
4         </properties>        
5     </destination>

The method in using the <mx:Mothod> component to configure remote objects inside the <mx:RemoteObject> component, see the previous section of this article for details. The core of real remote object access is the object's adapter and connection channel:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <service id="remoting-service"
 3     class=""
 4     messageTypes="">
 5     <adapters>
 6         <adapter-definition id="dotnet" class="" default="true"/>
 7     </adapters>
 8 
 9     <default-channels>
10         <channel ref="my-amf"/>
11     </default-channels>
12 
13     <destination id="fluorine">
14         <properties>
15             <source>*</source>
16         </properties>        
17     </destination>
18 </service>

In actual development, we can customize the communication channel, and by default, the default connection channel provided by FluorineFx is used:

1     <channels>
2         <channel-definition id="my-amf" class="">
3             <endpoint uri="http://{}:{}/{}/" class=""/>
4             <properties>
5                 <!-- <legacy-collection>true</legacy-collection> -->
6             </properties>
7         </channel-definition>
8     </channels>