Web 服务使用旧的代理设置?

发布于 2024-07-25 10:04:13 字数 1552 浏览 2 评论 0原文

我有一个相当令人困惑的问题。

Web 服务 A - 由 Win32 应用程序和各种其他 Web 应用程序直接调用
Web 服务 B - 由相同的 Win32 应用程序和一组不同的其他 Web 应用程序直接调用

我正在努力将对 B 的引用添加到 A 中,以便我们可以使用 B 提供的功能,而无需手动将该代码重写/重新集成到 A 中。我正在使用的 PC 上有 A 的开发副本,并且正在远程服务器上调用 B 的测试副本(测试服务器通过我们的托管提供商通过互联网访问)

我相信我的代码已经准备好用于测试,但每次我在本地副本上测试它时,都会收到以下错误。

无法建立连接,因为目标机器主动拒绝它 10.1.X.XX:8080

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

错误消息中列出的内部 IP 是我们旧的 BorderManager 网关。 它不再使用,我检查了所有 Machine.Configs、Web.Configs、注册表项,甚至对我的 PC 上 2MB 以下的所有文件进行了全文搜索,以查找其中列出的 IP。 我仔细检查了 Internet 选项连接设置,但该设置是由公司范围内的组策略管理的。 我已联系网络人员来验证该 IP 是否未在当前应用的策略中的任何位置列出。

除了尝试跳过使用它的代码并获取上面显示的异常之外,我在任何地方都找不到它。

我使用 Web 服务 B 的代码是:

 Dim oZip As New ZipTerr.ZIPTerr
 oZip.Url = "https://test.test.com/ZIPTerr/ZIPTerr.asmx" ' This really shouldn't be hardcoded...
 oZip.PreAuthenticate = True
 oZip.Credentials = New System.Net.NetworkCredential("username", "password")
 aCity = oZip.GetCities(pstrZip, Date.Now())

调用 oZip.GetCities() 失败并出现上述错误。 错误消息中的 IP 并不以任何方式表明它是从我们的本地网络中获取的,它是一个 10.* 私有 IP,而测试服务器具有有效的实时可公开访问的 IP。

有任何想法吗??

更新: 这两个 Web 服务均采用 .NET 2.0

I've got a rather confusing problem.

Web Service A - Called directly by Win32 App, and various other web applications
Web Service B - Called directly by same Win32 App and a different set of other Web Applications

I'm working on adding a reference to B into A, so that we can use the functionality B provides without rewriting/reintegrating that code manually into A. I have a develop copy of A on my PC that I'm working with, and am calling a test copy of B on a remote server (the test server is accessed over the internet at our hosting provider)

I believe to have my code ready for testing, but every time I go to test it on my local copy, I get the following error.

No connection could be made because the target machine actively refused it 10.1.X.XX:8080

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

The internal IP listed in the error message was our old BorderManager gateway. It is no longer in use, I've checked all Machine.Configs, Web.Configs, registry entries, even gone so far as doing a full text search of all files on my PC under 2MB for the IP listed there. I double checked the Internet Options Connections settings, but that is managed by a group policy company wide. I've called in a networking guy to verify that the IP is not listed anywhere in the currently applied policy.

I can't find it anywhere except when trying to step over the code that uses it, and getting the exception shown above.

The code I have for using Web Service B is:

 Dim oZip As New ZipTerr.ZIPTerr
 oZip.Url = "https://test.test.com/ZIPTerr/ZIPTerr.asmx" ' This really shouldn't be hardcoded...
 oZip.PreAuthenticate = True
 oZip.Credentials = New System.Net.NetworkCredential("username", "password")
 aCity = oZip.GetCities(pstrZip, Date.Now())

It fails on the call to oZip.GetCities() with the above error. The IP in the error message does not in any way indicate it's made it out of our local network, it's a 10.* private IP, whereas the test server has a valid live publicly accessible IP.

Any ideas??

Update:
Both web services are in .NET 2.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清醇 2024-08-01 10:04:14

在这种情况下,底层 System.Net 库将不会使用 Internet 设置值,因为代码作为服务运行。

MS 对于在 .config 文件中没有特定设置的情况下如何派生其代理设置的详细信息有点粗略。

这里有一些可以尝试的事情:-

一个命令行使用:-

 ProxyCfg -d

这将删除 WinHTTP 组件使用的任何代理设置(在 .NET 出现之前,该组件被设计为通过代码在此类服务器设置中使用)。

 ProxyCfg -u

将当前用户的 Internet 代理设置复制到 WinHTTP 使用的系统范围设置。

最好在调用应用程序的 web.config 中自行配置代理设置:-

<system.net>
  <defaultProxy enabled="true">
     <!-- if above set to true configure below accordingly if false delete below-->
     <proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>
  </defaultProxy>
</system.net>

The underlying System.Net libraries will not be using the Internet Settings values in this case since the code is running as a service.

MS are a little sketchy on the details of how its proxy settings are derived in the absence of specific settings in the .config files.

Here are some things to try:-

One command line use:-

 ProxyCfg -d

This would remove any proxy settings used by the WinHTTP component (which was designed to be used in just such a server setting by code prior to the advent of .NET).

 ProxyCfg -u

Copies the current users Internet proxy settings to the system-wide setting used by WinHTTP.

Better yet configure the proxy settings yourself in the web.config of the calling application:-

<system.net>
  <defaultProxy enabled="true">
     <!-- if above set to true configure below accordingly if false delete below-->
     <proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False"/>
  </defaultProxy>
</system.net>
过去的过去 2024-08-01 10:04:14

最佳猜测:

错误可能来自于您计算机上不存在的代码。 Web 服务 A 和 B 是否在您的计算机上运行?

或者它被硬编码在 dll 中,而该 dll 的源代码不在您的计算机上。

希望这对

设拉子有帮助

Best Guess:

Either the error is coming from code that is not on your machine. Is Web service A and B running on your machine?

Or it is hard coded in a dll where the source for the dll is not on your machine.

Hope this helps

Shiraz

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文