4

我可以从 Windows 窗体程序调用第 3 方供应商的 Web 服务就好了。当我尝试从 WCF Web 服务调用相同的 Web 服务和 Web 方法以及相同的 URL 时,我收到以下错误:

ExportValuationPolicyNumber:Exception=System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed 
because connected host has failed to respond 66.77.241.76:80

   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream()
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at TFBIC.RCT.WCFWebServices.ExpressLync.ValuationServiceWse.ExportValuationPolicyNumber(String PolicyNumber) in c:\Source\TFBIC.RCT.WCFWebServices\TFBIC.RCT.WCFWebServices\Web References\ExpressLync\Reference.cs:line 519
   at TFBIC.RCT.WCFWebServices.ValuationService.ExportValuationPolicyNumber(String PolicyNumber) in c:\Source\TFBIC.RCT.WCFWebServices\TFBIC.RCT.WCFWebServices\ValuationService.svc.cs:line 97

我基本上是在尝试为供应商 .asmx/WSE3 服务编写 WCF 包装器。让我们不要下车 - 但微软说 WCF 可以调用 WSE3,但只有在 SSL 开启的情况下,我的供应商 - 不管你信不信 - 不允许 SSL 连接。所以我坚持编写包装器,以便可以从 BizTalk 2009 调用。现在,我正在通过控制台程序测试包装器。

我什至可以做些什么来调试?我在调用 .asmx 服务的 WCF 服务之前和之后添加了 EventLog 跟踪 - 所以我知道这就是它正在发生的地方(加上上面错误中的行号)。

我的 web.config 中有以下内容:

<microsoft.web.services3>
        <diagnostics>
                <trace enabled="true" 
                           input="c:\inetpub\wwwroot\wsetraces\InputTrace.webinfo" 
                           output="c:\inetpub\wwwroot\wsetraces\OutputTrace.webinfo" />
                <detailedErrors enabled="true" />
        </diagnostics>
</microsoft.web.services3>

我已将目录完全访问权限授予所有人-但那里没有出现任何痕迹。

我可以寻找或尝试接下来调试哪些东西?

从理论上讲,“ping”结果应该无关紧要,因为该网站正在使用调用它的 Windows 窗体程序工作。

尽管如此 - 这是 Ping 显示的内容,对我来说它看起来有点可疑:

C:\Users\uxnxw01>ping rct.msbexpress.net

Pinging rct.msbexpress.net [66.77.241.56] with 32 bytes of data:
Reply from 10.193.99.5: Destination net unreachable.
Reply from 10.193.99.5: Destination net unreachable.
Request timed out.
Reply from 10.193.99.5: Destination net unreachable.

Ping statistics for 66.77.241.56:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

谢谢,

尼尔·沃尔特斯


WireShark 分析

我确实运行了 Wireshark - 在下面的评论中发布了一些结果。不过,多读后,它并不总是说“Destination Unreachable”。但在它失败的情况下,我永远不会得到任何数据回传。我仍然很困惑下一步该做什么。我一直在比较数据包,但它很慢而且令人困惑。例如,我仍然没有找到我在请求数据包中传递的密钥(特定的 policyNum)。我还在有效的语句中看到了一些“无法到达的目标”语句。

在有效的那个中,我从来没有看到 66.77.241.76,我只看到我们公司的代理。但我在配置(或代码)中看不到任何告诉 WSE3 使用或不使用代理的内容。


远程登录结果:

C:\Users\uxnxw01>telnet 66.77.241.56 80
Connecting To 66.77.241.56...Could not open connection to the host, on port 80:
Connect failed

C:\Users\uxnxw01>telnet 66.77.241.76 80
Connecting To 66.77.241.76...Could not open connection to the host, on port 80:
Connect failed

我不确定这证明了什么。就像我说的,我绝对可以通过直接调用其 WSE3 接口从 Windows 窗体调用相同的 Web 服务。我知道我可以通过这种方式到达那里。

我认为这两个程序的主要区别是一个在 Win Form 下运行并直接调用 WSE3。那个有效。失败的代码基本上是 99% 相同的代码,作为 WCF 服务发布,因此它在 IIS 下运行(然后控制台程序调用我机器上的 WCF/IIS 服务,该服务又调用 WSE3 服务)。

IIS 不使用相同的代理是否有某些原因?

4

4 回答 4

3

感谢以上所有帮助 - 但这是真正的答案:

valservice.Proxy = new System.Net.WebProxy(" http://10.192.xx.xx:8080 ", true);

在 IIS 下运行的 WCF 服务显然没有使用相同的代理,所以我在代码中手动设置了它。我将发布另一个问题,看看是否有办法在配置文件中执行此操作。

于 2009-11-18T15:58:31.373 回答
2

Ping 请求(ICMP 数据包)可能在防火墙上被禁用。因此,完全有可能不会得到 ping 响应,同时能够访问不同端口上的盒子。

尝试使用telnet80 端口连接到 66.77.241.56,看看是否有响应。

telnet 66.77.241.56 80

或者,tracerte上述 IP 地址可能会为您的一位网络管理员提供一些更详细的信息,因为它可能同样与网络路由或 NAT 有关。

第三种可能性是您可能需要在SOAP 客户端实例Proxy上显式设置属性。SoapHttpClientProtocolWinForms 会自动获取此信息,但从 Web 服务/应用程序中并非如此。

于 2009-11-17T23:39:11.017 回答
2

您可能希望使用Wireshark查看网络流量的情况。

于 2009-11-17T23:44:51.803 回答
0

也请参阅我对其他人帖子的评论,但此外,与您的诊断日志相关,这是我在配置中用于转储 WCF 跟踪日志的 XML:

<configuration>

    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
                <listeners>
                    <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "MyService.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>

</configuration>
于 2009-11-18T15:00:07.207 回答