【发布时间】:2012-02-09 10:27:25
【问题描述】:
我必须使用 SOAP 与在 .Net 上编写的 Web 服务进行通信。此 Web 服务需要带有证书和用户/密码的 ws-security 身份验证。身份验证是这样定义的:
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
有没有为 PHP 实现 ws-security 的库?或者,可能在某个地方可以找到一个很好的例子来说明如何使用 PHP 的 SoapClient 来实现这一点?我发现的只是一个仅适用于 UserNameToken 的 sn-p:
$ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
$token = new \stdClass();
$token->Username = new \SoapVar('<username>', XSD_STRING, null, null, null, $ns);
$token->Password = new \SoapVar('<password>', XSD_STRING, null, null, null, $ns);
$wsec = new \stdClass();
$wsec->UsernameToken = new \SoapVar($token, SOAP_ENC_OBJECT, null, null, null, $ns);
$headers = new \SoapHeader($ns, 'Security', $wsec, true);
$this->soapClient = new \SoapClient('<wsdlurl>',array());
$this->soapClient->__setSoapHeaders($headers);
但是服务响应
The security context token is expired or is not valid. The message was not processed.
【问题讨论】:
标签: php soap ws-security