我正在尝试使用AS3做一个REST客户端,下面是本教程:US/as3/dev/WSb2ba3b1aad8a27b061afd5d7127074bbf44-8000.html
我的代码如下:
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变量和url使用的url变量。
REST服务是一个简单的GET,如果我在浏览器中键入url,它将显示返回的JSON。
但是在我的AS3中,当我调用restServiceCall()方法时,它返回以下错误:
打开URL 'https://localhost:8443/restcomponent/tesimalex?‘时出错发生了一个错误:[IOErrorEvent type="ioError“bubbles=false cancelable=false eventPhase=2 text=”错误#2032:流错误. URL:https://localhost:8443/restcomponent/tesimalex?"]
有人知道怎么回事吗?
发布于 2016-01-06 16:24:13
好的..。这是安全问题..。我在服务器上禁用了SSL,然后我的flash应用程序成功地与我的REST服务进行了连接。
https://stackoverflow.com/questions/34632954
复制相似问题