Flex vs. NET Interop (vii): Understanding FLUORINEFX Environment Configuration (remote objects, gateways, channels, destinations)
Note: This article was originally planned in the previous "flex and. NET Interoperability (VI): Flex and. NET Collaborative development tool FluorineFX", taking into account that the content of the article is too long to be divided into two articles.
Remote object access in Flex, where the server provides a remote service object (Remotingservice object), the process by which the flex client invokes the remote object through the appropriate access technology.
The approach to accessing webservice, described in previous articles in this series, is a remote object approach, except that he is remote access based on Web services (Webservie), not remote access based on remote objects (Remoting object). In order to achieve direct object-based remote access is cumbersome, and then FluorineFX specifically for us to provide this functionality, through the FLUORINEFX Core library to develop remote objects (Remoting object) services, how to achieve the specific? FluorineFX requires the [Remotingservice] tag to provide remote Object Services for remote objects, and look at the detailed definition of the following remotingserviceattribute:
1 [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
2 public sealed class RemotingServiceAttribute : Attribute
3 {
4 public RemotingServiceAttribute();
5 public RemotingServiceAttribute(string serviceName);
6 }
As you can see from the example code in the previous article, use the. NET (C #) defines a remote object service class for sample and assigns it [Remotingservice], as detailed below:
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 }
The example of a remote object that flex client calls FluorineFX has been in the process of building fluorinefx and. NET development environments from the previous article, and here we look at this example:
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>
1 <mx:Script>
2 <![CDATA[
3 import mx.rpc.events.ResultEvent;
4 internal function onClick():void
5 {
6 service.Echo(txtInput.text);
7 }
8
9 internal function onResult(evt:ResultEvent):void
10 {
11 txtResult.text = evt.result.toString();
12 }
13 ]]>
14 </mx:Script>