任何人都可以建议如何解析nuSOAP标题并检查 ie:我需要在服务器端解析此标头并验证每个请求的凭据。 p>
div>用户名/密码/签名 code >来自以下SOAP请求 p>
< SOAP-ENV:Header>
< SOAP-ENV:Header xmlns:wsa =“http://admin.example。 com“>
<用户名> testuser< /用户名>
<密码> test123456< /密码>
<签名> 5595610031002< /签名>
< / SOAP-ENV:标题>
< / SOAP-ENV:Header>
code> pre>
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.