I have to create PHP, SOAP API. I need to authenticate SOAP client from SOAP Server. This is the code of SOAP Client.
$client = new SoapClient("cust.wsdl",array(
"trace" => 1,
"exceptions" => 0,
"user" => 'username',
"pass" => 'password'));
$result = $client->getDetails($value1);
I need to capture and validate these username and password from server (SOAP SERVER) side. This is my SOAP Server Code
class getDb {
//return DATA
}
$server = new SoapServer("cust.wsdl");
$server->setClass("getDb");
$server->handle();
I need to Validate Client's Username and Password from SOAP Server.
Anyone know how to capture SOAP Username and Password ("user" => 'username', "pass" => 'password') from SOAPSERVER please provide.
Auth details can be captured like follows.
if(($_SERVER['PHP_AUTH_PW']!= $pass || $_SERVER['PHP_AUTH_USER'] != $login)|| !$_SERVER['PHP_AUTH_USER'])
{
header('WWW-Authenticate: Basic realm="Test auth"');
header('HTTP/1.0 401 Unauthorized');
echo 'Auth failed';
exit;
}
Any output can be generated for header('HTTP/1.0 401 Unauthorized');