我目前正在Ubuntu 10.4上用Rails 3.0開發Ruby on Rails應用程序。 我打算使用Adobe Flex作爲前端。出於這個原因,我在Windows XP上使用Virtual Box安裝了Flash Builder 4。此虛擬機的Internet連接已橋接。Flex Ruby on Rails http xml請求錯誤
Flex應用程序目前只包括檢索從Rails應用程序在Ubuntu本地主機上運行一個XML文件,一個簡單的HTTP請求:3000:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="plansService.send()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="plansService"
url="http://192.168.1.102:3000/plans/list" />
</fx:Declarations>
<fx:Script>
<![CDATA[
private function printPlans():void {
for each (var xm:XML in plansService.lastResult.plans.plan) {
trace("my name is "+ xm.child("name"));
}
}
]]>
</fx:Script>
</s:Application>
在Flash Builder網絡管理器的HTTP請求被顯示爲加工。響應在那裏幷包含正確的XML數據。 但是當Flex應用程序加載在瀏覽器中我得到這個錯誤:
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file://C:\Documents and Settings\susi\Adobe Flash Builder 4\naturalstudy\bin-debug\naturalstudy.swf cannot load data from localhost:27813.
at mx.netmon::NetworkMonitorImpl()[/ndepot/fb_401/ide_builder/ActionscriptProjects/src/mx/netmon/NetworkMonitorImpl.as:81]
at mx.netmon::NetworkMonitorImpl$/init()[/ndepot/fb_401/ide_builder/ActionscriptProjects/src/mx/netmon/NetworkMonitorImpl.as:49]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::kickOff()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:2620]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::preloader_completeHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:2539]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\preloaders\Preloader.as:515]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
我GOOGLE了這一點,因此在嘗試這些事情:
- 增加使用網絡= false添加到Flash Builder編譯器選項項目
- 添加crossdomain.xml文件到Rails項目公用文件夾:
<?xml version="1.0" encoding="utf-8"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all" />
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
但它仍然無法正常工作和錯誤是一樣的。 我認爲問題在於Flex應用程序試圖從localhost接收一些內容:27813 ...但我堅持在這一點上。 幫助將不勝感激!
非常感謝你!將localhost:27813添加爲可信位置解決了問題! :D – daniela 2011-01-05 21:55:34
*幸運射擊* :) – Heikki 2011-01-05 22:17:02