我正在实例化这样的PHP Soap客户端:
$client = new SoapClient('http://localhost:8731/MathService?wsdl',array(
'login' => "test2", 'password' => "test"));
当我在上面执行此操作时,请求包含:
Authorization: Basic dGVzdDI6dGVzdA==
但我的CustomUserNamePasswordValidator没有提取上述内容。我只是在控制台应用程序中运行WCF服务,所以我不知道如何在服务主机上设置客户端凭据。我使用TransportWithCredentialOnly与Basic HTTP和Message =“UserName”。我的CustomUserNamePassword Validator是硬编码的,只接受test和test作为用户名和密码,但即使我将test2传递给SoapClient,操作仍然会通过。
我将安全模式更改为TransportCredentialOnly,将运行clientCredentialType更改为Basic并且它可以工作。