Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Stream Error when calling a REST Service

Guest
Jan 06, 2016 Jan 06, 2016

I am trying to do a REST client using AS3, I am following this tutorial :http://help.adobe.com/en_US/as3/dev/WSb2ba3b1aad8a27b061afd5d7127074bbf44-8000.html

My code is the following:

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;

  //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() );

}

The only diference between my code and the one in the tutorial is the URL variables, that I commented, and the url used.

My REST service is a simple GET, if I type the url in the browser it shows me the JSON returned.

But in my AS3, when I call the method restServiceCall() it returns the following error:

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?"]

Anyone knows whats wrong?

TOPICS
ActionScript
924
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jan 06, 2016 Jan 06, 2016

I really don't know about that link but as I see  it's a security problem, because it doesn't open in the browser also for some security reason! as I see that you've disabled the secure browsing that's why it's working in your browser but not in flash. Anyway try to upload the file to the server because the security conditions well be different then check if it'll work there, use a text field to show the data.

Translate
Enthusiast ,
Jan 06, 2016 Jan 06, 2016

Add the file extension after the file name and make sure that you're allowed to access that fie hosted on the server

https://localhost:8443/restcomponent/tesimalex.???

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 06, 2016 Jan 06, 2016

Its not a file... Its a REST GET method... If I type that url in the browser it shows me the json returned.

rest.png

I tried with this: http://ip.jsontest.com/ and it works, can it be from using https instead of http?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 06, 2016 Jan 06, 2016

I really don't know about that link but as I see  it's a security problem, because it doesn't open in the browser also for some security reason! as I see that you've disabled the secure browsing that's why it's working in your browser but not in flash. Anyway try to upload the file to the server because the security conditions well be different then check if it'll work there, use a text field to show the data.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 06, 2016 Jan 06, 2016
LATEST

You are right. My solution was to disable SSL and then the REST call worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines