views:

337

answers:

1

We have a Flex client and a server that is using the Spring/Blazeds project.

After the user logs in and is authenticated, the spring security layer sends a redirect to a new URL which is where our main application is located.

However, within the flex client, I'm currently using HTTPService for the initial request and I get the redirected page sent back to me in its entirety.

How can I just get the URL so that I can use navigatetourl to get where the app to go where it needs to?

Any help would greatly be appreciated. Thanks!

A: 

One solution would be to include a token inside a comment block on the returned page, for instance:

<!-- redirectPage="http://localhost/new-location" -->

then check for it's presence inside the HTTPService result handler. The token's value could then be used in your call to navigateToURL.

Another solution would be to examine the HTTP response headers and extract the value of the "Location" header using ActionScript. Consider using the AS3 HTTP Client lib.

From the examples page http://code.google.com/p/as3httpclientlib/wiki/Examples To determine the 'Location' header from the response:

var client:HttpClient = new HttpClient();

var uri:URI = new URI("http://localhost/j_security_check");

client.listener.onStatus = function(event:HttpStatusEvent):void {
  var response:HttpResponse = event.response;
  // Headers are case insensitive

  var redirectLocation:String = response.header.getValue("Location");
  // call navigateToURL with redirectLocation
  // ... 
};

// include username and password in the request

client.post(uri);

NOTE: AS3 HTTP Client depends on AS3 Core and AS3 Crypto libs.

Saheed
Sorry - this is a late reply but this response was very helpful!
fortpointuiguy
Glad it helped you :)!
Saheed