2012-02-09 11 views
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. 

答えて

0

で応答し、それは、より高度なだった、私は何年も前にそれを使用しNuSoap

を見てくださいデフォルトのphp soapクライアントよりも優先されます。特にクロスプラットフォームで通信するとき

+0

悲しいことに、NuSoapはWSセキュリティをサポートしていません – Timur

+0

ああ、申し訳ありませんが、私はそれがと思った:( – Billy2mates

+0

https://code.google.com/p/wse-php/source/browse /soap-wsse.phpはトリックになるでしょう。それはX509キー等をサポートしています – Timur