简体   繁体   中英

PHP nusoap webservice security

I am writing soap server and soap client in php. For Authentication of soap services , i want to use "usernametoken" for security. Can anyone send me the example applied in server and client using nusoap.

I am using nusoap to write the soap services.

Thanks & Regards, neetha

SERVER Side:

function doAuthenticate(){    
if(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW']) )
          {
           //here I am hardcoding. You can connect to your DB for user authentication.    

           if($_SERVER['PHP_AUTH_USER']=="abhishek" and $_SERVER['PHP_AUTH_PW']="123456" )
                return true;
           else
               return  false;                   

           }
}

Call this doAuthenticate function for every operation in server.If it is returning true then only allow the client/user to communicate.

CLIENT side

// includes nusoap class
require_once('../lib/nusoap.php');

// Create object
$client = new nusoap_client('<wsdl path>?wsdl', true);
//Setting credentials for Authentication 
$client->setCredentials("abhishek","123456","basic");
..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM