使用代理后面的.Net Core 2.0连接到SOAP服务

编程入门 行业动态 更新时间:2024-10-28 21:29:49
本文介绍了使用代理后面的.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服务( www.webservicex/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 (www.webservicex/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("www.webservicex/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.

原因是带有代理设置的 Core 2.0中的错误。它没有使用WinINet(IE / Edge)代理设置,并且您无法配置单独的代理,更多信息请参见 github/dotnet/wcf/issues/1592 。

The reason was a bug in 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 github/dotnet/wcf/issues/1592.

将项目升级到 Core 2.1之后,并更新System.ServiceModel.Http等依赖于最新的稳定版本(以我的情况为4.5.3),则使用IE / Edge代理设置。

After upgrading the project to 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服务

本文发布于:2023-11-14 18:47:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588254.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   Core   Net   SOAP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!