c# - SOAP 客户端从控制台应用程序工作,从 wcf 服务中调用时超时

标签 c# wcf web-services soap

这是交易: 我有一个类库,它通过 SOAP 客户端调用 Web 服务。 当从控制台应用程序中调用时,它工作正常。 当从由 http 调用调用的 WCF 服务中进行调用时,我收到“EndpointNotFoundException - 没有端点监听 http://blablabla.asmx 可以接受消息。这通常是由不正确的地址或 SOAP 操作引起的...”

app.config 和 web.config 都包含完全相同的客户端配置

所以,这是怎么回事?顺便说一句,WCF 是从 Visual Studio 本地运行的。我尝试调用的 SOAP 网络服务位于互联网上。

这就是服务模型配置的样子。它使用基本身份验证,用户和密码在类库的代码中设置:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="VocalServerSoap">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://pseudourl.asmx"
    binding="basicHttpBinding" bindingConfiguration="VocalServerSoap"
    contract="VocalWebService.VocalServerSoap" name="VocalServerSoap" />
</client>

architecture

最佳答案

哦……沮丧! 在我认为我已将其确定为权限问题(根据我之前的帖子)后,它恢复为相同的超时行为。

最终这一切都是因为代理......事实证明( from msdn ):

Applications running as an NT Service or as part of ASP.NET use the Internet Explorer proxy server settings (if available) of the invoking user. These settings may not be available for all service applications.

所以我对从 WCF 服务中调用的 SOAP 服务的请求根本没有配置代理...因此出现无端点异常。

为了克服这个问题,我必须在 SOAP 客户端绑定(bind)中手动声明代理:

<binding name="VocalServerSoap" proxyAddress="http://<your proxy address>:<proxy port>"
      useDefaultWebProxy="false">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>

那为什么我认为这是权限?怎么时不时就起作用了? 好吧,Fiddler 给我带来了真正的困惑......激活 fiddler 时一切正常,因为所有传出请求都正确路由到代理,因为 fiddler 使用系统代理。

我不敢相信这几乎浪费了我生命中的一天:(

关于c# - SOAP 客户端从控制台应用程序工作,从 wcf 服务中调用时超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19212060/

相关文章:

c# - ASP.NET 的图表控件

c# - 使用 CaSTLe Windsor 的 WCF 依赖注入(inject) - 请帮忙?

c# - 删除 xml :space ="preserve" of XML file using C#

c# - wcf服务如何授权

c# - 远程服务器返回意外响应 : (400) Bad Request, WCF

java - 如何阻止 Apache CXF 将基元转换为对象类型?

web-services - 尝试比较 Web 服务响应和文件中的预期 xml

c# - AngularJS 与 Web 服务交互最佳实践

c# - 具有序言和结尾的设计模式

c# - 与此 Ninject 代码等效的 Autofac 是什么?