c# - 如何修复“客户端身份验证方案‘匿名’禁止 HTTP 请求”
问题描述
我在实现与 WCF 服务对话的客户端时遇到了一些问题。这是由另一家公司托管的 WCF,因此我无权访问其代码。我使用 Visual Studio 中的 Connected Service 提供程序工具来生成客户端代码,以便我可以发出请求,并且在我的本地计算机上一切正常。我在我们的开发环境中遇到问题,如果我尝试向客户端发出请求,我会收到以下错误:
The HTTP request was forbidden with client authentication scheme 'Anonymous'
我一直在查看 Provider 工具生成的客户端代码(代码很多),我认为它可能与以下代码块有关。
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
result.MaxBufferSize = int.MaxValue;
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
return result;
解决方案
这更多地与企业网络内的防火墙规则相关联。
我在使用非授权代理时遇到了同样的问题,但使用 ntlm 解决了安全代理问题ClientCredentialType
推荐阅读
- html - 当我更改默认元素的数量时,CSS垂直滚动动画变得很奇怪
- python - 从具有最大并集的集合中找到最少集合的最快方法?
- python - 如何向 django-rest-framework 的 ModelSerializer 添加额外的属性?
- c# - 即使启用了自动绑定,也找不到程序集
- r - 使用 R&ec2 Server 从 PostgreSQL 调用大数据
- hyperledger-fabric - 调用链码函数的延迟
- laravel - 使用explode(Eloquent模型Laravel)在列中获取一串IDS
- mysql - sql脚本从脚本中获取英文文本
- javascript - Uncaught TypeError: (((item.value + 1) / total) * 100).floor 不是函数
- python-3.x - 如何在 python 中模拟 s3 对象?