0

I want to call web service which has basic authentication . once url get authenticated then want to call particular service example xyz()
which takes 2 parameter and return a flag .

Please help me ?

Thanks in advance............

1 Answers1

1

For basic authentication you have to encode your username and password in service call headers like this:

import mx.utils.Base64Encoder;
private function authAndSend(service:HTTPService):void
{
        var encoder:Base64Encoder = new Base64Encoder();
        encoder.insertNewLines = false;
        encoder.encode("someusername:somepassword");

        service.headers = {Authorization:"Basic " + encoder.toString()};                                                
        service.send();
}

already discussed at HTTP Basic Authentication with HTTPService Objects in Adobe Flex/AIR

Community
  • 1
  • 1
a.s.t.r.o
  • 3,261
  • 5
  • 34
  • 41
  • Also make sure you use POST. Auth headers get stripped if you try to use GET. – chrsmrtn Mar 27 '12 at 16:42
  • Thanks Adnan . I have used above basic authentication it works fine . But now I am facing problem in calling xyz() function from webservice . How to call xyz() ,how to pass the parameter . Please help . – user1263794 Mar 28 '12 at 04:55
  • You can change the `service.url` if you need to call another URL (I suppose you use **HTTPService**) – a.s.t.r.o Mar 28 '12 at 15:13