提供的 URI 方案“https”无效; .Net Core 3.1 中预期的“http”

问题描述 投票:0回答:2

我们开发了一个 .Net Core 3.1 应用程序,它使用 WCF Web 服务(也是我们开发的)。在我们办公室一切都很好。 我们在开发中不使用 SSL,但在生产服务器中使用。 在生产中,当应用程序尝试使用 Web 服务时,会收到下一个错误

[500].System.ArgumentException: 提供的 URI 方案“https”无效;预期为“http”。 (参数“via”)位于 System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)....

¿ 如何将 http 调用“转换”为 https? 我们找到了有关 .net 4.5 的信息,但在 .net core 3.1 中没有找到

PD:我们无法从办公室访问生产 wsdl

asp.net-core web-services wcf
2个回答
8
投票

在您的 web.config 文件中。
更改自

<security mode="None">

<security mode="Transport">

或在代码中设置

System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
...
binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
...

此更改将允许您使用 https 而不是 http。


0
投票

对于 SOAP 1.2,答案很简单,从使用

System.ServiceModel.Channels.HttpTransportBindingElement
切换到
System.ServiceModel.Channels.HttpsTransportBindingElement

© www.soinside.com 2019 - 2024. All rights reserved.