我的WCF客户端具有以下配置。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyService" closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536"
maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myservername/MyGreatServices/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="MyService"
contract="XXX.Ixxx" name="MyService" />
</client>
</system.serviceModel>
但在尝试运行应用程序时出错:
mscorlib.dll中发生了'System.ServiceModel.Security.MessageSecurityException'类型的异常,但未在用户代码中处理 附加信息:HTTP请求未经授权,客户端身份验证方案为“协商”。从服务器接收到的认证标头是“协商oXoweKADCgEBonEEb2BtBgkqhkiG9xIBAgIDAH5eMFygAwIBBaEDAgEepBEYDzIwMTYwMTEyMjAwNDAwWqUFAgMH13imAwIBKakUGxJVUy5LV09STEQuS1BNRy5DT02qGzAZoAMCAQGhEjAQGw51c21kY2tkYXAxMDg3JA ==”
在IIS上启用了Anonimous和Windows身份验证
答案 0 :(得分:3)
更改
<transport clientCredentialType="Windows" />
到
<transport clientCredentialType="Ntlm" />