在代理后面使用 .Net Core 2.0 连接到 SOAP 服务 [英] Connecting to a SOAP service with .Net Core 2.0 behind a proxy

查看:27
本文介绍了在代理后面使用 .Net Core 2.0 连接到 SOAP 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Visual Studio 2017.

I'm using Visual Studio 2017.

我注意到在代理后面时无法从 .Net Core 2.0 连接到 SOAP 服务(当直接连接到互联网时,它正在工作,并且从 .Net Core 1.1 应用程序通过代理连接时)它也有效).

I have noticed that it was not possible to connect to a SOAP service from a .Net Core 2.0 when being behind a proxy (when connected directly to the internet it's working and when connecting through the proxy from a .Net Core 1.1 app it's working too).

我创建了一个调用公共 SOAP 服务的小测试程序(控制台应用程序)(http://www.webservicex.net/globalweather.asmx).通过更改此程序的目标(.Net Core 1.1/.Net Core 2.0),我可以重现该问题.

I have created a little test program (Console app) that calls a public SOAP service (http://www.webservicex.net/globalweather.asmx). By changing the target of this program (.Net Core 1.1 / .Net Core 2.0) I can reproduce the problem.

这是示例代码(用于连接到 Web 服务的类已使用 VS 2017 的 Connected Services 组件生成):

Here is the sample code (the classes for connecting to the web service have been generated with VS 2017's Connected Services component):

BasicHttpBinding binding = new BasicHttpBinding();

EndpointAddress address = new EndpointAddress("http://www.webservicex.net/globalweather.asmx");

GlobalWeatherSoapClient client = new GlobalWeatherSoapClient(binding, address);

var response = client.GetCitiesByCountryAsync("France").Result;

我已经完成了网络捕获(使用 Wireshark),当这个问题发生时,我看不到从我的计算机发出的 HTTP 请求.有谁知道出了什么问题?也许我没有以正确的方式调用这项服务.

I have done a network capture (with Wireshark) and when this problem happens I can see no HTTP request coming out from my computer. Does anybody know what is going wrong ? Maybe I am not calling this service the right way.

提前致谢

推荐答案

我遇到了同样的问题,Wireshark 中没有传出的 http 请求.该项目必须使用带有凭据的公司代理连接到 https 地址,因此设置了 BasicHttpSecurityMode.Transport.

I had the same problem, no outgoing http requests in Wireshark. The project had to use a corporate proxy with credentials to connect to a https address, thus BasicHttpSecurityMode.Transport was set.

原因是 .net Core 2.0 中带有代理设置的错误.它没有使用 WinINet (IE/Edge) 代理设置,您无法配置单独的代理,更多信息请点击此处 https://github.com/dotnet/wcf/issues/1592.

The reason was a bug in .net Core 2.0 with proxy settings. It hasn't used the WinINet (IE/Edge) proxy settings and you wasn't able to configure a separate proxy, more info here https://github.com/dotnet/wcf/issues/1592.

将项目升级到 .net Core 2.1,并将 System.ServiceModel.Http 和其他依赖项更新到最新的稳定版(我的情况是 4.5.3)后,使用 IE/Edge 代理设置.

After upgrading the project to .net Core 2.1, and update System.ServiceModel.Http and other dependcies to latest stable (4.5.3 in my case), the IE/Edge proxy settings are used.

这篇关于在代理后面使用 .Net Core 2.0 连接到 SOAP 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆