2016-01-06 62 views
0

我试图做使用AS3 REST客户端调用REST服务时,我下面这个教程流错误:http://help.adobe.com/en_US/as3/dev/WSb2ba3b1aad8a27b061afd5d7127074bbf44-8000.html使用AS3

我的代码如下:

import flash.events.Event; 
import flash.events.ErrorEvent; 
import flash.events.IOErrorEvent; 
import flash.events.SecurityErrorEvent; 
import flash.net.URLLoader; 
import flash.net.URLRequest; 
import flash.net.URLRequestMethod; 
import flash.net.URLVariables; 

var url:String = "https://localhost:8443/restcomponent/tesimalex"; 

var requestor:URLLoader = new URLLoader(); 

function restServiceCall():void 
{ 
    trace("Calling REST Service..."); 
    //Create the HTTP request object 
    var request:URLRequest = new URLRequest(url); 
    request.method = URLRequestMethod.GET; 

    //Add the URL variables 
    // var variables:URLVariables = new URLVariables(); 
    // variables.method = "test.echo"; 
    // variables.api_key = "123456ABC"; 
    // variables.message = "Able was I, ere I saw Elba.";    
    // request.data = variables; 

    //Initiate the transaction 
    requestor = new URLLoader(); 
    requestor.addEventListener(Event.COMPLETE, httpRequestComplete); 
    requestor.addEventListener(IOErrorEvent.IO_ERROR, httpRequestError); 
    requestor.addEventListener(SecurityErrorEvent.SECURITY_ERROR, httpRequestError); 
    requestor.load(request); 
} 

function httpRequestComplete(event:Event):void 
{ 
    trace(event.target.data);  
} 

function httpRequestError(error:ErrorEvent):void{ 
    trace("An error occured: " + error.toString());  
} 

之间的唯一性差异我的代码和教程中的代码是URL变量,我评论过,以及使用的网址。

我的REST服务是一个简单的GET,如果我在浏览器中键入url,它会显示我返回的JSON。

但在我的AS3,当我打电话restServiceCall()返回以下错误的方法:

Error opening URL ' https://localhost:8443/restcomponent/tesimalex ?' An error occured: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: https://localhost:8443/restcomponent/tesimalex ?"]

任何人都知道什么是错?

+0

错误#2032通常会在Flash Player因任何原因无法访问使用的URL(URL不可用,被阻止...)时被触发,因此请尝试验证您的URL是否可访问... – akmozo

回答

0

好的......这是一个安全问题......我在我的服务器上禁用了SSL,然后我的闪存应用程序设法与我的REST服务通信。

+0

您可以运行您的本地主机上的端口443上的REST服务?从我读过的内容来看,我猜测你要么有证书错误(Flash不信任你的证书),要么出现协议错误(Flash不想使用SSL,除非它实际上是443端口)。 – Brian