gpt4 book ai didi

.net - 为什么我可以从浏览器访问 WSDL 文件,但不能从应用程序访问?

转载 作者:行者123 更新时间:2023-12-04 14:43:04 28 4
gpt4 key购买 nike

我们在部署可在我们的开发环境中运行但在生产环境中运行的 Web 服务时遇到问题。部分问题在于我们的生产服务器是负载平衡的,因此要升级其中一台服务器,我们必须将其从负载平衡中取出并尝试单独测试服务器,这是一个挑战。

我正在使用的计算机名为 Web01,我用来测试的计算机名为 Ts01。在两台机器上,我都修改了主机文件以将 example.com 重定向到 Web01 上网站的相应 IP。

我正在测试在每台机器上访问网络服务的两种方式:

  • http://www.example.com/services/myservice.asmx?WSDL 的简单浏览器调用。
  • 一个 VB6 测试应用程序,它使用上面引用的 WSDL 通过 SOAPClient 调用网络服务。

测试结果如下:

                   Browser              VB6 App    Ts01             OK                   OK    Web01            OK                  ERROR

The test seems to work OK for every situation except the VB6 app installed on the web server. The Error I get back is :

-2147024809 - WSDLReader:Loading of the WSDL file failed HRESULT=0x80070057 - WSDLReader:XML Parser failed at linenumber 0, lineposition 0, reason is: The system cannot locate the object specified.

HRESULT=0x1

I get the same error back on Ts01 if I supply a bad WSDL address in the VB6 app. It seems as if the VB6 application on Web01 can't access the web service dll on Web01, which is a big problem.

It may be worth noting that it works on my local developer machine as well, where I have the VB6 app and the web service installed on the same machine.

Why might the VB6 app be having trouble communicating with the web service via SOAPClient when run from the same box that the web service exists?


I used fiddler to inspect the headers of the requests on my local machine calling our dev server. Here's the difference between the browser and SOAPclient requests:

Browser:

GET http://devserver/services/myservice.asmx?WSDL HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-shockwave-flash, */*
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: devserver
Cookie: SIFR-PREFETCHED=true

SOAPClient(来自 VB6 应用程序):

GET http://devserver/services/myservice.asmx?WSDL HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Host: hbhswebnet
Connection: Keep-Alive
Pragma: no-cache

我不确定这些信息是否有用,但也许有用。

最佳答案

这是一个通用模式:

Q: "x" works in the browser, but fails in a program that's doing the same thing the browser is doing. What's wrong?

A: the program is not doing the same thing the browser is doing.

浏览器显式设置了您的程序未设置的 header (特别是因为您使用的是非常过时的 SOAPClient)。各种网络设备和软件在决定如何响应您的请求时可能会查看这些 header 。

您应该使用 Fiddler 查看这两种情况(浏览器和程序)的网络流量或其他东西,然后仔细查看浏览器行为方式和程序行为方式之间的差异。然后,您可以将程序更改为类似于浏览器,或者要求您的网络人员降低安全性,以便您的程序可以访问该服务。

关于.net - 为什么我可以从浏览器访问 WSDL 文件,但不能从应用程序访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3374573/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com