因此,我有两个项目调用相同的第三方SOAP服务。两个项目(项目A和项目B)具有相同的配置,并且都运行.NET 4.7.2。 项目B正常运行,但是项目A抛出以下异常:
向https://XXXXXXXXXX发出HTTP请求时发生错误。 这可能是由于服务器证书不是 在HTTPS情况下使用HTTP.SYS正确配置。这也可以 由客户端和客户端之间的安全绑定不匹配引起 服务器。
我已经在项目A中设置了安全协议以匹配项目B(Ssl3 && Tls)。我还尝试使用HTTP代替HTTPS。
项目A- Web Api项目 .NET 4.7.2
项目B- 控制台应用 .NET 4.7.2
任何建议将不胜感激。
答案 0 :(得分:1)
添加代理服务器设置(不知道我们有一个设置)解决了我的问题。
请参见下面的示例代码:
private string SendDataExample()
{
using (var client = new ServiceClient())
{
SetProxy(client.Endpoint.Binding as BasicHttpBinding);
}
}
private void SetProxy(BasicHttpBinding binding)
{
binding.ProxyAddress = new Uri($"http://localHost:8080");
binding.BypassProxyOnLocal = false;
binding.UseDefaultWebProxy = false;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
}