1 Reply Latest reply on Dec 19, 2011 8:23 AM by sadascq

    webservice:how to set "login" & "password" like this... in flex

    sadascq Level 1

      Hello, I'm Thai guy ,if any sentence or some grammar  is not correct or mistake ,I'm sorry for that.

       

      In php, I test my webservice like this:

      ____________________________________________________________________________

      [client-side]

      $client = new SoapClient("plus.wsdl",array(

          "trace" => 1,

          "exceptions" => 0,

          "login"=>"51011111",

           "password"=>"1234"

      ));

       

      $ar= $client->plus(5, 2);

      ___________________________________________________________________________

      [server-side]

      function plus($num1,$num2) {

       

      $h=array();

       

      $user=trim($_SERVER['PHP_AUTH_USER']);

      $pwd=trim($_SERVER['PHP_AUTH_PW']);

       

       

      $h[0]=$user;                  // check sever-side can get user from client

      $h[1]=$pwd;                    // check sever-side can get password from client

      $h[2]=$num1+$num2;

       

      return $h;

      }

       

      ///////////////////////////////////////////////////////////////////////////////

      $server = new SoapServer("plus.wsdl");

      $server->addFunction("plus");

      $server->handle();

      __________________________________________________________________

      This is basic test for next step of my authentication so It's work.

      but now I wanna use in Flex but I don't know how to set 

      "login"=>"51011111",

           "password"=>"1234"

      ____________________________________________________________________

       

      in the other way I know I should soapheader for authen but I don't know how to use it because

      it's error #1009 and I don't know how to get value(user,pwd) in server-side if use soapheader.

       

       

      Thank you very much.

       

       

       

       

       

       


        • 1. Re: webservice:how to set "login" & "password" like this... in flex
          sadascq Level 1

          no one help me- -'

           

          but now I can figure it out.

           

          solution:

          private function authAndSend():void
          {
                 
          var encoder:Base64Encoder = new Base64Encoder();
                  encoder
          .encode("someusername:somepassword");

                  ws
          .httpheaders = {Authorization:"Basic " + encoder.toString()};                                               
                  ws
          .send();
          }

           

          adove code(flex) is equivalent to php code (below)

           

          $client = new SoapClient("plus.wsdl",array(

              "trace" => 1,

              "exceptions" => 0,

              "login"=>"51011111",  //someusername

               "password"=>"1234" //somepassword

          ));