【问题标题】:Stream Error when calling REST services using AS3使用 AS3 调用 REST 服务时出现流错误
【发布时间】:2016-01-06 12:16:03
【问题描述】:

我正在尝试使用 AS3 做一个 REST 客户端,我正在学习本教程:http://help.adobe.com/en_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。

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

但在我的 AS3 中,当我调用 restServiceCall() 方法时,它返回以下错误:

打开网址“https://localhost:8443/restcomponent/tesimalex?”时出错一个 发生错误:[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: https://localhost:8443/restcomponent/tesimalex?"]

有谁知道怎么回事?

【问题讨论】:

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

标签: rest actionscript-3


【解决方案1】:

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

【讨论】:

  • 你能在 localhost 的 443 端口上运行你的 REST 服务吗?根据我的阅读,我猜您要么有证书错误(Flash 不信任您的证书)或协议错误(Flash 不想使用 SSL,除非它实际上是端口 443)。
猜你喜欢
  • 2020-08-18
  • 1970-01-01
  • 1970-01-01
  • 2015-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多