使用代理后面的.Net Core 2.0连接到SOAP服务
我正在使用Visual Studio 2017。
I'm using Visual Studio 2017.
我注意到,当位于.NET Core 2.0后面时,无法从.Net Core 2.0连接到SOAP服务。代理(当直接连接到Internet时它正在工作,并且当从.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.
以下是示例代码( VS 2017的Connected Services组件已生成用于连接到Web服务的类)。
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.