如何使用PHP使用WCF安全服务?

时间:2011-03-17 19:30:53

标签: php wcf wcf-security

我正在尝试使用PHP来使用安全的WCF服务,我无法弄清楚语法。我认为它会像下面这样简单:

$client = new SoapClient('https://localhost/service.svc?wsdl', array('userName' => "test", "password" => 'pass'));

但它在PHP中引发异常An error occurred when verifying security for the message. ,我从应用程序日志MessageSecurityException: Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.获得以下内容

无论我是否尝试提供凭据,似乎都会引发此错误,所以除非我的语法错误,否则不是这样。

我看到一些帖子也怪这个标题,但我无法弄清楚如何指定一个,更不用说应该是什么了。

值得一提的是,只要它不安全,我就可以成功使用该服务。我也可以使用.NET客户端在任何模式下成功使用它。

1 个答案:

答案 0 :(得分:3)

我有一个非常相似的问题并解决了它。看看这篇文章:How to consume a WCF Web Service that uses custom username validation with a PHP page?