WSSE安全PHP SoapServer-未理解标头

WSSE安全PHP SoapServer-未理解标头,php,soap-client,soapserver,Php,Soap Client,Soapserver,我有一个带有WSSE安全标头的客户端调用: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:w

我有一个带有WSSE安全标头的客户端调用:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-7BCCD9337425FBA038149772606059420"><wsse:Username>USERNAME</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NONCE</wsse:Nonce><wsu:Created>2017-06-17T19:01:00.594Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
   <soapenv:Body>
      <ns:FUNCTION/>
   </soapenv:Body>
</soapenv:Envelope>
一旦属性MustUnderstand=1,我就会从服务器变成exception:Header not Understand

  • 如何理解标题
  • 如何在SoapServer端进行WSSE验证

  • 解决方案非常棘手!我不知道为什么会从SoapServer以这种方式处理此问题,但以下是解决方案:

    class ServerClass {
    
        public function Security($data) {
            // ... do nothing
        }
    
        public function myFunction(){
            // here the body function implementation
        }
    }
    
    我们需要在类中定义一个函数,该函数使用头标记的名称处理soap请求,头标记保存soap:mustUnderstand属性。该函数不需要以某种方式实现


    就这些

    解决方案非常棘手!我不知道为什么会从SoapServer以这种方式处理此问题,但以下是解决方案:

    class ServerClass {
    
        public function Security($data) {
            // ... do nothing
        }
    
        public function myFunction(){
            // here the body function implementation
        }
    }
    
    我们需要在类中定义一个函数,该函数使用头标记的名称处理soap请求,头标记保存soap:mustUnderstand属性。该函数不需要以某种方式实现


    就这些

    穆塔托斯的问题/回答让我走上了正确的道路。我在班级结构之外工作,因此对我有效的方法如下:

    function Security($data)
    {
        $username = $data->UsernameToken->Username;
        $password = $data->UsernameToken->Password;
        //check security credentials here
    }
    
    $server = new SoapServer("schema/wsdls/FCI_BookingPullService.wsdl", array('soap_version' => SOAP_1_2));
    $server->addFunction("Security");
    $server->handle();
    
    本质上,正在定义一个与SOAP头“”同名的函数(忽略名称空间),然后告诉服务器使用“addFunction”方法处理头


    从范围的角度来看并不理想,如果这是一个问题,请尝试类方法。

    Mutatos的问题/答案让我走上了正确的轨道。我在班级结构之外工作,因此对我有效的方法如下:

    function Security($data)
    {
        $username = $data->UsernameToken->Username;
        $password = $data->UsernameToken->Password;
        //check security credentials here
    }
    
    $server = new SoapServer("schema/wsdls/FCI_BookingPullService.wsdl", array('soap_version' => SOAP_1_2));
    $server->addFunction("Security");
    $server->handle();
    
    本质上,正在定义一个与SOAP头“”同名的函数(忽略名称空间),然后告诉服务器使用“addFunction”方法处理头

    从范围的角度来看,这并不理想,如果这是一个问题,请尝试类方法