2012-02-09 3 views
3

SOAP를 사용하여 .NET에서 작성된 웹 서비스와 통신해야합니다. 이 웹 서비스에는 인증서와 사용자/암호가 포함 된 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 비누 클라이언트보다. 특히 교차 플랫폼에서 통신 할 때

+0

슬프게도 NuSoap은 WS 보안을 지원하지 않습니다. – Timur

+0

아, 죄송합니다. 나는 생각했습니다. ( – Billy2mates

+0

https://code.google.com/p/wse-php/source/browse와 같은 것입니다. /soap-wsse.php는 속임수입니다. X509 키 등을 지원합니다. – Timur