1
我對Flex很新穎(幾乎被扔進它......大聲笑)。我正在嘗試顯示我在Web服務中創建的消息。我一直得到返回錯誤「安全錯誤訪問網址目的地:DefaultHTTP」用於Flex的REST風格的Web服務
這是我的代碼的副本......我知道這可能是簡單的東西。我創建了數據服務配置HTTP服務,我測試了運行和測試時...只是有出了一點小麻煩一切都已成功
<?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"
xmlns:restsrv="services.restsrv.*"
minWidth="955" minHeight="600" applicationComplete="init()">
<fx:Declarations>
<mx:HTTPService id="service" url="http://servername/RestService/Service.svc/XMLService/hi" method="POST" resultFormat="e4x" />
<restsrv:Restsrv id="restsrv"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
showBusyCursor="true"/>
<s:CallResponder id="RESTfulResult"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.http.HTTPService;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
protected function form_creationCompleteHandler(event:FlexEvent):void
{
RESTfulResult.token = restsrv.RESTful();
/* rESTfulTextInput.text = RESTfulResult.toString(); */
service.send();
}
]]>
</fx:Script>
<s:Form id="form" creationComplete="form_creationCompleteHandler(event)">
<s:FormItem label="RESTful">
<s:TextInput id="rESTfulTextInput" text="{RESTfulResult.lastResult as String}"/>
</s:FormItem>
</s:Form>
</s:Application>
這是代碼加入你的建議正確的語法時的樣子LXX
<?xml version="1.0" encoding="utf-8"?>
<cross-domain-policy>
<allow-access-from domain="http://my-server-name-dev3/RestService/Service.svc/XMLService/hi" />
</cross-domain-policy>
<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"
xmlns:restsrv="services.restsrv.*"
minWidth="955" minHeight="600" applicationComplete="init()">
我檢查,我們有專門的服務器上的crossdomain.xml本地主機。我試圖在我的代碼中輸入這個,但得到的格式錯誤。 – nholloway4 2012-02-16 19:28:27
您必須在crossdomain.xml中有該行,而不是在客戶端代碼中。 – Ixx 2012-02-18 23:40:44
真棒謝謝,我會嘗試這個 – nholloway4 2012-02-20 01:10:26