【发布时间】:2014-06-30 17:57:46
【问题描述】:
我正在尝试连接到 WCF 服务,但是当我这样做时出现此错误:
HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是 '基本领域="ServiceGateway"'。
我知道我在 WCF 客户端上设置客户端凭据时进行身份验证:
new wcfClient(enpointconfigurationName, url)
{
ClientCredentials =
{
UserName =
{
UserName = "yyy",
Password = "zzz"
}
}
}
编辑
我在 web.config 中有这个 WCF 配置:
<client>
<endpoint address="xxx" binding="basicHttpBinding" bindingconfiguration="myBinding" contract="yyy" name="myName" />
</client>
<basichttpbinding>
<binding name="myBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01: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="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basichttpbinding>
【问题讨论】:
-
阅读。我的配置错了吗?
-
尝试使用安全模式和 clientCredentialType,例如尝试将安全模式设置为“Transport”,将 clientCredentialType 设置为“Basic”
标签: c# wcf authentication