亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Flex與.NET互操作 了解FluorineFx的環(huán)境配置(遠程對象、網(wǎng)關(guān)、通道、目的地)

 更新時間:2009年06月15日 20:11:24   作者:  
Flex中的遠程對象訪問,也就是服務(wù)端提供一個遠程服務(wù)對象(RemotingService Object),在Flex客戶端通過相應(yīng)的訪問技術(shù)去調(diào)用遠程對象的過程。

在本系列文章的前面幾篇文章中所介紹的訪問Webservice的方法,也就是一種遠程對象方法,只不過他是基于WEB服務(wù)(WebServie)的遠程訪問,不是基于遠程對象(Remoting Object)的的遠程訪問。要想直接實現(xiàn)基于對象的遠程訪問是比較麻煩的,然后FluorineFx則專門為我們提供了該功能,通過 FluorineFx的核心庫來開發(fā)遠程對象(Remoting Object)服務(wù),具體是怎么實現(xiàn)的呢?

FluorineFx要求為遠程對象提供[RemotingService]標(biāo)記來提供遠程對象服務(wù),看看下面的RemotingServiceAttribute的詳細定義:

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


     從上一篇文章中的示例代碼可以看出,使用.NET(c#)定義了一個Sample的遠程對象服務(wù)類,并為其指定了[RemotingService],詳細如下:

 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     }

     從上一篇文章中搭建FluorineFx與.NET的開發(fā)環(huán)境過程中就已經(jīng)出現(xiàn)過Flex客戶端調(diào)用FluorineFx的遠程對象示例,下面我們在來看看這個示例:

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>

     如上可實現(xiàn)遠程對象訪問,通過Flex的非可視化組件<mx:RemoteObject>進行遠程對象連接。其中的 source屬性指定遠程對象,格式為全限定名(命名空間+類名)。destination屬性是非常重要的,這決定了Flex客戶端是否可以正確的訪問到遠對象,相關(guān)配置如下:

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

     在<mx:RemoteObject>組件內(nèi)部使用<mx:Mothod>組件配置遠程對象中的方法,詳細見本文前面部分。要真實實現(xiàn)遠程對象訪問的核心是對象的適配器和連接通道:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <service id="remoting-service"
 3     class="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         <channel ref="my-amf"/>
11     </default-channels>
12 
13     <destination id="fluorine">
14         <properties>
15             <source>*</source>
16         </properties>        
17     </destination>
18 </service>

     實際開發(fā)中我們可以進行自定義通信通道,默認情況下是使用FluorineFx為我們提供的默認連接通道:

1     <channels>
2         <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
3             <endpoint uri="http://{server.name}:{server.port}/{context.root}/Gateway.aspx" class="flex.messaging.endpoints.AMFEndpoint"/>
4             <properties>
5                 <!-- <legacy-collection>true</legacy-collection> -->
6             </properties>
7         </channel-definition>
8     </channels>

相關(guān)文章

最新評論