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

标签 .net wcf web web-services

我在网站的 Web 服务调用中收到此 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. 

我已经确认绑定(bind)(在 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 连接?而在控制台应用程序中,它只是一个连接。

最佳答案

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

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

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

关于.net - 来自网站但不是来自控制台应用程序的 Web 服务调用中的 EndpointNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2282863/

相关文章:

.net - 将 WinForms 应用程序升级到 WPF

c# - 在处理大文件时,通过 Windows 服务运行 ffmpeg.exe 无法完成

c# - 为什么我会收到 OleDBException "No value given for one or more required parameters?"

c# - 具有 WCF 通信的 Service Fabric 可靠服务

sql - 如何从数据库中选择数据并通过WCF服务返回它?

wcf - 为单个操作启用 SOAP 消息检查

使用 Web 服务器作为负载均衡器时的 Java Web session cookie 路径问题

c# - 单击 ListBoxItem 区域内的任何控件时触发器 SelectedIndex 发生更改

web - 网站Admob

c# - HttpWebResponse 超时