Can any one please advice how to parse nuSOAP headers and checking the username/password/Signature
from the below SOAP Request
<SOAP-ENV:Header>
<SOAP-ENV:Header xmlns:wsa="http://admin.example.com">
<Username>testuser</Username>
<Password>test123456</Password>
<Signature>5595610031002</Signature>
</SOAP-ENV:Header>
</SOAP-ENV:Header>
i.e: i need to parse this header on server side and validate the credentials for every request.
Am not sure but i found an alternative to track the credentials by using the following code. let me explain.
The code $sSoapRequest = file_get_contents('php://input');
which returns the entire SOAP request to the server side...
The following 2 functions helps me to bring out the values..
function doAuthenticate()
{
$sSoapRequest = file_get_contents('php://input');
if(isset($sSoapRequest))
{
$sUsername = hookTextBetweenTags($sSoapRequest, 'Username');
$sPassword = hookTextBetweenTags($sSoapRequest, 'Password');
$sSignature = hookTextBetweenTags($sSoapRequest, 'Signature');
if($sUsername=='testuser' && $sPassword=='test123456' && $sSignature=='5595610031002')
return true;
else
return false;
}
}
function hookTextBetweenTags($string, $tagname) {
$pattern = "/<$tagname ?.*>(.*)<\/$tagname>/";
preg_match($pattern, $string, $matches);
return $matches[1];
}
and, use doAuthenticate()
method for every process in server side.