PHP security nusoap for webservice

I am writing a soap server and soap client in php. For authentication of soap services, I want to use "usernametoken" for security. Can someone send me an example applied on server and client using nusoap.

I use nusoap to record soap services.

Thanks and Regards, neetha

+3
source share
1 answer

SERVER:

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 each operation on the server. If it returns true, then allow only the client / user.

CLIENT'S 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");
..
+8
source

Source: https://habr.com/ru/post/1773596/


All Articles