【问题标题】:WCF calling a external service - communication faulted stateWCF 调用外部服务 - 通信故障状态
【发布时间】:2017-03-06 09:26:57
【问题描述】:

我正在使用 VS 2013 构建一个 winform 客户端。我想使用 3party java 安全和外部(使用带有证书的 https)Web 服务。

我可以访问 wsdl。我向我的 .net 项目添加了一个服务引用,引用了 Endpoint 的地址,并使用 wsHttpBinding 和传输配置了我的 web.config。 (我也尝试过 basicHttpBinding )

在代码中,我创建了一个客户端服务对象,我可以正常看到它的方法和数据类型。

我看到我一创建对象,InnerChannel 属性就处于故障状态模式,我不明白为什么。

Show my code in debug mode

问题是在调用任何服务对象方法时,都会报错:

“System.InvalidOperationException”类型的未处理异常 发生在 System.Xml.dll 中

“System.ServiceModel.CommunicationObjectFaultedException”发生在 System.ServiceModel.dll

附加信息:通信对象, System.ServiceModel.ChannelFactory`1 [myproyect.SR.NotificaWsPortType],不能用于通讯 因为它处于故障状态。

附加信息:出现反映“返回”的错误。

谁能帮帮我?

web.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
  <bindings>

    <wsHttpBinding>
      <binding name="NotificaWsBinding">
        <security mode="Transport">
          <transport clientCredentialType="Certificate" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
    <client>
        <endpoint address="https://<address here>"
            binding="wsHttpBinding" bindingConfiguration="NotificaWsBinding"
            contract="SR.NotificaWsPortType" name="NotificaWsPort" />
    </client>

</system.serviceModel>
</configuration>

【问题讨论】:

  • 我配置了...wsHttpBinding 和传输 - 您不应该使用此绑定,因为它不可互操作。请改用 basicHttpBinding。这应该在您使用服务元数据时为您选择。
  • 感谢您的回复。最初我使用 basicHttpBinding 但它也不起作用。我仍然有同样的问题。

标签: wcf


【解决方案1】:

我终于找到了答案。在 .NET 中映射 Web 服务时出现问题,因为 Web 服务是用 Java 开发的,并且存在微软技术的问题。 因此,我与服务提供商进行了交谈,他们对 java 没有任何问题,但对 .net 没有任何问题。他们改变了内部结构,这对我有用。

【讨论】:

    猜你喜欢
    • 2011-04-02
    • 1970-01-01
    • 2012-01-28
    • 2014-06-27
    • 2011-07-16
    • 1970-01-01
    • 2010-09-23
    • 2012-03-13
    • 1970-01-01
    相关资源
    最近更新 更多