'System.ServiceModel.Security.MessageSecurityException' 在 WCF 中
'System.ServiceModel.Security.MessageSecurityException' in WCF
我的 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>
但是在尝试 运行 应用程序时出现错误:
An exception of type 'System.ServiceModel.Security.MessageSecurityException' occurred in mscorlib.dll but was not handled in user code
Additional information: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oXoweKADCgEBonEEb2BtBgkqhkiG9xIBAgIDAH5eMFygAwIBBaEDAgEepBEYDzIwMTYwMTEyMjAwNDAwWqUFAgMH13imAwIBKakUGxJVUy5LV09STEQuS1BNRy5DT02qGzAZoAMCAQGhEjAQGw51c21kY2tkYXAxMDg3JA=='.
在 IIS 上启用了匿名和 Windows 身份验证
改变
<transport clientCredentialType="Windows" />
至
<transport clientCredentialType="Ntlm" />
我的 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>
但是在尝试 运行 应用程序时出现错误:
An exception of type 'System.ServiceModel.Security.MessageSecurityException' occurred in mscorlib.dll but was not handled in user code Additional information: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oXoweKADCgEBonEEb2BtBgkqhkiG9xIBAgIDAH5eMFygAwIBBaEDAgEepBEYDzIwMTYwMTEyMjAwNDAwWqUFAgMH13imAwIBKakUGxJVUy5LV09STEQuS1BNRy5DT02qGzAZoAMCAQGhEjAQGw51c21kY2tkYXAxMDg3JA=='.
在 IIS 上启用了匿名和 Windows 身份验证
改变
<transport clientCredentialType="Windows" />
至
<transport clientCredentialType="Ntlm" />