Thursday, October 01, 2009

Web Services - Basic Authentication in Flex

I need to expand on this - but critically when using webservices and basic authentication in Flex, go to the import WSDL option in the File menu. From there you can set your authentication credentials as follows:

var encoder:Base64Encoder = new Base64Encoder();
encoder.encode(_username + ":" + _password);
var encodedCredentials:String = encoder.flush ();

if (message.httpHeaders == null)
message.httpHeaders = {};
message.httpHeaders["Authorization"] = "Basic " + encodedCredentials;

More here on the Flex Live site.


Post a Comment

<< Home