我们在专用服务器上部署了使用集成 Windows 身份验证的 WCF 服务。客户端机器上会有 Windows 服务[windows 服务使用本地系统帐户]。当 Windows 服务中的 WCFServiceClient 访问 WCF 服务时我们得到一个错误。[如果 windows 服务在服务器机器上它工作正常]
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
我们不能允许匿名访问,也不能从 WCF 服务中删除 Windows 身份验证。有没有办法解决这个问题。
客户端的配置是
<basicHttpBinding>
<binding name="BasicServiceHttpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
服务器配置是
<basicHttpBinding>
<binding>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
/binding>
</basicHttpBinding>