Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
Add the file extension after the file name and make sure that you're allowed to access that fie hosted on the server
Copy link to clipboard
Copied
Its not a file... Its a REST GET method... If I type that url in the browser it shows me the json returned.
I tried with this: http://ip.jsontest.com/ and it works, can it be from using https instead of http?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You are right. My solution was to disable SSL and then the REST call worked.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now