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:
code highlighting produced by Actipro Codehighlighter (freeware)
http:// Www. CODEHIGHLIGHTER.COM/
--> 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")]
2PublicClassSample
3{
4 public sample ()
5 {
6
7
8 public String echo ( string text)
9 {
10  &NBSP 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[
3Import mx.rpc.events.ResultEvent;
4Internalfunction OnClick ():void
5{
6Service. Echo (Txtinput.text);
7}
8
9 Internal function onresult (evt:resultevent): void
10 {
11 txtresult.text = evt.result.tostring ();
12
13 &NBSP ]]
14 </ mx:script
Remote object access can be achieved by using Flex's non-visual Components <mx:RemoteObject> remote object connections. The Source property specifies the remote object in the form of a fully qualified name (namespace + class name). The destination attribute is very important, which determines whether the flex client can access the remote object correctly, and the related configuration is as follows:
--> 1 destination id = Fluorine
2 Properties
3 Source >*</ source 4
</ Properties &NBSP;&NBSP;&NBSP;&NBSP
5 </ Destination >
Use the <mx:Mothod> component inside the <mx:RemoteObject> component to configure methods in the remote object, as detailed in the previous section of this article. The core of realizing remote object access is the adapter and connection channel of the object:
--> 1?XML version="1.0"Encoding="UTF-8"?>
2<Service ID="Remoting-service"
3Class="Flex.messaging.services.RemotingService"
4 Messagetypes="Flex.messaging.messages.RemotingMessage">
5<Adapters>
6<Adapter-Definition ID="dotnet"Class="FluorineFx.Remoting.RemotingAdapter"Default="True"/>
7</Adapters>
8
9<Default-Channels>
10<ChannelRef="My-amf"/>
11</Default-Channels>
12
13 destination id = Fluorine
14 < Properties
15 Source >*</ source 16
</ Properties &NBSP;&NBSP;&NBSP;&NBSP;&NBSP
17 </ destination
18 </ service "
In actual development, we can customize the communication channel, by default is the use of FluorineFX to provide us with the default connection channel:
--> 1<Channels>
2<Channel-definitionId= "MY-AMF"Class= "Mx.messaging.channels.AMFChannel">
3<EndpointUri= "Http://{server.name}:{server.port}/{context.root}/gateway.aspx"Class = "Flex.messaging.endpoints.AMFEndpoint" />
4 &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP Properties
5 <!-- <legacy-collection>true</legacy-collection>
6 </ Properties
7 </ channel-definition
8 </ Channels