【问题标题】:WCF can't connect to an ASMX Web ServiceWCF 无法连接到 ASMX Web 服务
【发布时间】:2010-01-21 20:11:33
【问题描述】:

此时我正在使用 WCF 连接到远程 Web 服务 (asmx) 以进行测试。远程 Web 服务目前是不安全的(没有 https、没有用户名、密码)。我可以添加 WCF 服务引用,并且所有类都生成好了。当我调用网络服务时,它只是挂起。

所以我可以使用 SOAP UI 工具连接并返回数据就好了。我认为这是我的绑定有问题。有人看到我遗漏的任何东西吗?

  <system.serviceModel>
    <bindings>
      <!-- Need to change some settings here for HTTPS and Basic Auth when those go online-->
      <basicHttpBinding>
        <binding name="ServiceSoap" 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="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://<snip>/Service.asmx"
          binding="basicHttpBinding" bindingConfiguration="ServiceSoap"
          contract="PRIOrderService.ServiceSoap" name="ServiceSoap" />
    </client>
  </system.serviceModel>

【问题讨论】:

  • 您没有绕过代理,客户端请求在调用操作时将假定您的身份,并表示使用默认代理。配置文件看起来不错,我唯一能想到的就是代理,但这并不能解释普通的“挂起”(假设你创建了一个代理实例)
  • 感谢 bnkdev 和 Rubens,到目前为止还没有运气。我尝试使用上面链接的服务工具生成代理,并尝试连接,但仍然挂起。一定是某种网络问题。让我烦恼的是,我可以连接到 SOAP-UI。如果生成的代码确实像宣传的那样工作,那就太好了;)
  • Rubens,我使用了 srvutil 并生成了一个 service.cs 和 output.config 文件(默认名称)。我最终保留了通过添加服务引用生成的代理,但我确实设法将 output.config 文件放入我的 app.config 文件并让它工作。如果您发布并回答,我会将您标记为回答问题的人。再次感谢。

标签: wcf service asmx


【解决方案1】:

请求 wsdl 端点不会触发创建服务实例。如果您使用的是自定义服务主机工厂,请查看它,否则请查看服务实现的构造函数或调试服务方法本身。

【讨论】:

  • 嗯,这是一个初中的校队回答“检查基本的东西”。但是鲁本斯·法里亚斯再也没有回来,所以你得到了荣誉。无论如何,我非常感谢您花时间回答。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 1970-01-01
  • 1970-01-01
  • 2011-02-19
  • 1970-01-01
相关资源
最近更新 更多