来自网站的Web服务调用中的EndpointNotFoundException,但不是来自控制台应用程序

时间:2010-02-17 17:19:05

标签: .net wcf web web-services

我从网站上通过网络服务调用获得此EndpointNotFoundException,而如果我从控制台应用程序执行此操作则同样有效。 这是更详细的异常消息:

Could not connect to https://******. TCP error code 10060:
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 ***.***.***.***:443. 

我已经确认绑定(在web.configapp.config中)是相同的,所以我不明白为什么它在一个案例中起作用而在另一个案例中不起作用。

<basicHttpBinding>
<binding name="ServicePortBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
 receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
 bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
 maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
 messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
 useDefaultWebProxy="true">
 <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
 <security mode="Transport">
  <transport clientCredentialType="None" proxyCredentialType="None"
   realm="" />
  <message clientCredentialType="UserName" algorithmSuite="Default" />
 </security>
</binding>
</basicHttpBinding>

如果您需要更多详细信息,请与我们联系。

修改
好的,这是我遗漏的可能导致问题的原因。这一切都发生在公司防火墙背后。 可能是防火墙阻止它从网站运行,因为它是从现有“网络进程”产生的HTTP连接?而在控制台应用程序中,它只是一个连接。

3 个答案:

答案 0 :(得分:4)

您需要在web.config中添加代理绕过

  <system.net>
    <defaultProxy>
      <proxy
      usesystemdefault = "true"
      proxyaddress="http://theproxyaddress:PortNumber"
      bypassonlocal="false"
/>
    </defaultProxy>
  </system.net>

这将允许您通过防火墙打开与服务的连接

答案 1 :(得分:0)

您是否尝试过使用wireshark(或Fiddler,如果它是HTTP)来查看出站呼叫是否相同且正确?

答案 2 :(得分:0)

听起来像是一个许可问题。

您的网络应用程序通常以ASPNET或NETWORK SERVICE运行,而您的控制台应用程序将以您自己(您的帐户)运行。

有机会出现问题吗?

您是否在WCF服务器端进行任何可能适用于普通用户帐户的身份验证,但不适用于ASPNET / NETWORK SERVICE?