.net - .NET 4.5 DLL 访问 SOAP 1.2 服务的身份验证问题
问题描述
我们正在开发一个需要访问 SOAP 1.2 服务并使用 DLL 转换为 JSON 的项目。我们已经构建了所有内容,但被 .NET 4.5 中的身份验证问题所困扰,而这些问题在 .NET 5 中不会发生。我们认为这是一个简单的配置问题,但可能已经让 myoptic 试图让它工作。好奇是否有人遇到过类似的问题并有任何见解......
背景:
- 受保护的 SOAP 使用 IIS Web 服务器上的 Windows 身份验证 (NTLM) 进行保护,无需基于角色的身份验证。
- SOAP 服务基于 SOAP 1.2
- SOAP 服务消费者客户端必须在 DLL(而不是 EXE)中工作才能与 Web 应用程序集成;由于客户端代码位于 DLL 中,因此无法更改父应用程序的配置;在 .NET 4.5 Framework 中工作(我们有在 .NET 5 中工作的代码);而且,我们无法触及托管 SOAP 1.2 服务的服务器。
- WCF 用于在 DLL 中创建 SOAP 绑定
- 使用 WSHttpBinding 类是因为 SOAP 1.2 协议
- 当前在 DLL 中配置的绑定
我们的问题:
- 我们在调用绑定函数时收到“HTTP 请求未经授权,客户端身份验证方案‘匿名’。从服务器收到的身份验证标头是‘NTLM,Negotiate’”异常
- 示例代码:
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.None;
EndpointAddress endpointAddress = new EndpointAddress("http://...SummaryService.svc");
ServiceClient client = new ServiceClient(binding, endpointAddress);
var result = await client.SomeFunctionAsync();
注意:从 .NET 5.0 应用程序运行此代码时,没有问题;我仅在 .NET 4.5 .DLL/.EXE 中看到此错误。
有什么建议吗?TIA
解决方案
您可以按照以下步骤检查您的配置:
检查您的安全模式并设置为
TransportCredentialOnly
。确保服务器端和客户端是相同的绑定。
设置代理类以允许模拟。
Customer_PortClient proxy = new Customer_PortClient(); proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
推荐阅读
- python - pd.DataFrame 中的 Nan(对称矩阵)
- wordpress - 我需要一个在帖子或页面更新时激活的钩子
- python - 是否可以忽略列表的最后一个元素而不必创建另一个列表并且不修改原始列表?
- c# - 我在一个 c# 面向对象的类中,我有这两个简单的类
- odata - 在驼峰式案例中获取 OData 元数据
- java - 如何从 jtextfield 中选择一个字符串,插入单引号'',然后在 mysql 语法中使用它
- sql - 单列与多列索引,用于单独但始终在一起的连接
- mysql - 在 SQL 中计算一个组
- ros - 调用“cmake”失败
- javascript - 是否可以在输入字段中显示之前检查(防止显示)十进制长度的值?