首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSSE安全PHP SoapServer-报头未被理解

WSSE安全PHP SoapServer-报头未被理解
EN

Stack Overflow用户
提问于 2017-06-17 19:23:04
回答 2查看 1.7K关注 0票数 1

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

代码语言:javascript
复制
<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>

作为SoapServer,我有一个简单的例子:

代码语言:javascript
复制
// the SOAP Server options
$options=array(
    'trace' => true
    , 'cache_wsdl' => 0
    , 'soap_version' => SOAP_1_1
    , 'encoding' => 'UTF-8'
);

$wsdl = 'http://localhost/index.php?wsdl';

$server = new \SoapServer($wsdl, $options);
$server->setClass('ServerClass');
$server->handle();
$response = ob_get_clean();
echo $response;

一旦属性MustUnderstand = 1,我就从服务器变成例外:头不被理解。

  1. 如何理解标题?
  2. 如何在SoapServer端进行WSSE验证?
EN

回答 2

Stack Overflow用户

发布于 2017-06-18 13:20:34

解决办法很棘手!我不知道为什么SoapServer用这种方式来处理这个问题,但是下面是解决方案:

代码语言:javascript
复制
class ServerClass {

    public function Security($data) {
        // ... do nothing
    }

    public function myFunction(){
        // here the body function implementation
    }
}

我们需要在我们的类中定义一个函数,它使用header标记的名称来处理soap请求,该标签保存着soap:芥末理解属性。该函数不需要以某种方式实现。

就这样!

票数 5
EN

Stack Overflow用户

发布于 2019-05-26 14:07:33

穆塔托斯的问题/答案使我走上了正确的道路。我在班级结构之外工作,所以对我有用的是以下几点:

代码语言:javascript
复制
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‘方法处理标头。

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44608568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档