Flex+BlazeDS集成開發的編譯問題

Flex 調用遠程或所在web應用的 BlazeDS服務時,必須建立和遠端的通道channel,才能正常通信。
1. 通常的方式是 Flex 在編譯時就指定遠程的端點 Endpoint,service-config.xml 中的Endpoint 配置是 例如:

<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"

編譯時指定的方式是在加編譯參數,例如:
[quote] -services "services-config.xml" -context-root "/HelloBlazeds"[/quote]
services-config.xml 需要放在當前目錄下,或者指定BlazeDS所在的配置文件路徑。

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postId=12209

2. 在 <mx:RemoteObject/> 對象中指定Endpoint參數:
例如:
 <mx:RemoteObject id="roOrder" destination="Hello" showBusyCursor="true" endpoint="http://server:8080/HelloBlazeDS/messagebroker/amf" >

1) 全路徑: endpoint="http://server:8080/HelloBlazeDS/messagebroker/amf" >
2) 基於contextRoot: endpoint="/HelloBlazeDS/messagebroker/amf" >
3) 基於當前路徑: endpoint="messagebroker/amf" >

總結:
對於Flex+BlazeDS集成開發,方式1,和2.1),2.2) 對於企業應用來說都不是最佳方案,因爲他將 contextroot寫死了,不便於移植,也就是說,編譯後的 swf 放到其他應用下無法調用BlazeDS服務;
而對於互聯網應用,如果假定 endpoint地址比較固定,編譯時指定contextroot或endpoint全路徑則是較好的選擇,例如一個從google搜索信息Flex的小程序,放到桌面也能跑起來。

[參考資料]
1. http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postId=12209
2. http://www.iteye.com/topic/238127
發佈了15 篇原創文章 · 獲贊 0 · 訪問量 2639
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章