dounan9070 2012-04-11 15:58
浏览 163
已采纳

nuSOAP:服务器端的头部身份验证

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.

  • 写回答

1条回答 默认 最新

  • douwen1213 2012-04-12 10:33
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?