Asp.net與Flex交互測試記錄
一、利用asp.net為Flex提供數據服務,flex為前端表現。
二、flex通過三種方式四種代碼實現來取數據。分別為
HttpService、
WebService、
RemoteObject、
RemoteObjectAMF0。
三、Project文件夾中的
Vs2010Service提供HttpService、Webservice服務;
Vs2008RemoteObject提供RemoteObject服務。
四、FluorineFx.NET+RemoteObjectAMF0文件為附加文件。
五、<sessionState cookieless="AutoDetect"></sessionState>
設置可兼容客戶端禁用Cookie(要在Flex項目中傳遞回sessionid)
六、asmx中使用session需要[WebMethod(EnableSession = true)] 如此設置。
七、安裝FluorineFx.NET+RemoteObjectAMF0文件下的setup(FluorineFx.NET).exe
可以將項目模板集成到2005和2008中,不支持vs2010。
八、使用七中的模板建立普通網站(FluorineFx ASP.NET Web Site)項目。
將Console.aspx設為啟動頁,可進行類中的方法測試。
九、使用RemoteObjectAMF0時將renaun_com_RemoteObjectAMF0.zip解壓把src下的
com文件夾整體復制到flex項目中;
注意路徑與mxml同路徑;
RemoteObjectAMF0.as中的override public function setCredentials( username:String, password:String):void)修改成override public function setCredentials( username:String, password:String,charset:String=null ):void)
添加xmlns:renaun="com.renaun.rpc.*"到<mx:Application ……中。
十、使用普通RemoteObject在mxml的同目錄下添加services_config.xml文件內容如下:
<?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <service id="remoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"> <destination id="fluorine"> <channels> <channel ref="my-amf"/> </channels> <properties> <source>*</source> </properties> </destination> </service> </services> <channels> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> <endpoint uri="http://localhost:12432/ReomteFlex/Gateway.aspx" class="flex.messaging.endpoints.AMFEndpoint"/> </channel-definition> </channels> </services-config> |
注:http://localhost:12432/ReomteFlex/Gateway.aspx隨項目啟動的端口變化。
之后,Flex項目右鍵-屬性-Flex compiler-compiler參數(-locale en_US -services "services_config.xml")