如何解决使用 PHP 连接到受 WS-Security 保护的 Soap Web 服务
我有这个 wsdl 文件没有密码保护,我需要通过 php soap 客户端调用它:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:afe4="http://gsis.ggps.interoperability/Afe4Interface">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' >
<wsse:Username>****************************</wsse:Username>
<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>*****************************</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
其他参数 身体> 信封>
我正在尝试通过 php soapheader 进行连接:
class WsseAuthHeader extends SoapHeader {
private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
function __construct($user,$pass,$ns = null) {
if ($ns) {
$this->wss_ns = $ns;
}
$auth = new stdClass();
$auth->Username = new SoapVar($user,XSD_STRING,NULL,$this->wss_ns,$this->wss_ns);
$auth->Password = new SoapVar($pass,$this->wss_ns);
$username_token = new stdClass();
$username_token->UsernameToken = new SoapVar($auth,SOAP_ENC_OBJECT,'UsernameToken',$this->wss_ns);
$security_sv = new SoapVar(
new SoapVar($username_token,$this->wss_ns),'Security',$this->wss_ns);
parent::__construct($this->wss_ns,$security_sv,true);
}
****************** }
$wsse_header = new WsseAuthHeader($username,$password);
but it replies "A security error was encountered when verifying the message"
witch according to the manual means wrong usr or password.
Via postman i can connect.
Any suggestions?
解决方法
事实证明,将标头设置为原始数据可以解决问题。 感谢您的时间!!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。