3
我必須與使用SOAP在.Net上編寫的Web服務進行通信。此Web服務需要帶證書和用戶/密碼的ws安全認證。身份驗證是這樣定義的:PHP SOAP ws-security
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
是否有任何實現ws-security for PHP的庫?或者,可能在某處可以找到一個如何使用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-Security – Timur 2013-05-14 09:42:18
哦,對不起,我認爲它確實: – Billy2mates 2013-05-14 17:56:52
像https://code.google.com/p/wse-php/source/browse /soap-wsse.php就可以了,它支持X509按鍵等。 – Timur 2013-05-14 19:22:34