3
SOAPを使用して.NETで書かれたWebサービスと通信する必要があります。このWebサービスでは、証明書とユーザー/パスワードによるws-security認証が必要です。認証は次のように定義されています:PHP SOAP ws-security
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
PHPにws-securityを実装するライブラリはありますか?あるいは、どこかにPHPのSoapClientを使ってこれを実装する方法の良い例が見つかるかもしれませんか?私が見つけたすべては唯一UserNameToken
で動作するスニペットです:
$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.
悲しいことに、NuSoapはWSセキュリティをサポートしていません – Timur
ああ、申し訳ありませんが、私はそれがと思った:( – Billy2mates
https://code.google.com/p/wse-php/source/browse /soap-wsse.phpはトリックになるでしょう。それはX509キー等をサポートしています – Timur