我有一个用于 wsHttpBinding 和 TransportWithMessageCredential 的 IIS 托管 WCF 服务,具有以下绑定配置(我从空间绑定中删除了所有属性)
<wsHttpBinding>
<binding name="BindingName" .../>
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
具有以下服务行为:
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Windows" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
匿名身份验证被禁用,Windows 身份验证被启用。
在客户端,使用有效的 Windows 用户和密码设置凭据,但每次调用服务时都会出现以下异常:
HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“协商,NTLM”。---> System.ServiceModel.Security.MessageSecurityException:HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“协商,NTLM”。---> System.Net.WebException:远程服务器返回错误:(401)未经授权。
使用 WCF 服务的自托管版本,它可以在有效的 Windows 帐户下正常运行。
任何帮助表示赞赏。