【问题标题】:WCF unable to find netTcpBindingWCF 找不到 netTcpBinding
【发布时间】:2011-08-04 07:19:11
【问题描述】:

我正在尝试创建一个可通过 webHttpBinding 和 netTcpBinding 访问的 WCF 服务。我已经成功地让 webHttpBinding 可以通过 Java 客户端访问,现在我正在努力让 netTcpBinding 正常工作。

我已经设置了这样的配置;

<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <behavior name="httpBehavior">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  <services>
    <service name="MR_Jukebox_Service.JukeboxService">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service/"/>
          <add baseAddress="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net/"/>
        </baseAddresses>
      </host>
      <endpoint address=""
                behaviorConfiguration="httpBehavior"
                binding="webHttpBinding"
                contract="MR_Jukebox_Service.IJukeboxService" />
      <endpoint address="mex"
                binding="mexHttpBinding"
                contract="MR_Jukebox_Service.IJukeboxService" />
      <endpoint address="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net"
                binding="netTcpBinding"
                bindingConfiguration=""
                contract="MR_Jukebox_Service.IJukeboxService" />
    </service>
  </services>
</system.serviceModel>

在同一个解决方案中,我有一个希望连接到 netTcpBinding 的测试应用程序,我右键单击“服务引用”并选择“添加服务引用...”。 当我点击“发现”时,它虽然说找到了服务;

下载“http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service”时出错。 请求失败,HTTP 状态为 404:未找到。 元数据包含无法解析的引用:“http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service”。 在http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service 处没有可以接受消息的端点监听。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。 远程服务器返回错误:(404) Not Found。 如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

但我也无法看到 netTcpBinding 以便我创建对它的服务引用。

我想知道是否有人能看出我做错了什么,因为它可能相当简单,但由于我缺乏 WCF 经验,所以没有注意到。

提前感谢您的帮助。

【问题讨论】:

  • 另外:您的 MEX 端点必须使用 IMetadataExchange 合同 - 不是您自己的服务合同!

标签: wcf nettcpbinding endpoint webhttpbinding


【解决方案1】:

尝试将您的 mex 端点更改为:

<endpoint address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange" />

您正在为 mex 端点使用您的服务合同,我认为这不会起作用。

您可以为 NetTcpBinding 设置一个类似的:

<endpoint address="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net/mex"
          binding="mexTcpBinding"
          contract="IMetadataExchange" />

【讨论】:

  • 谢谢,虽然我被第二部分扔了,但最终认为是 mexTcpBinding 而不是 mexNetTcpBinding。
  • 很高兴你能成功。抱歉打错了 - 我会编辑我的答案,所以它是正确的。
【解决方案2】:

我已经成功地让 webHttpBinding 可以通过 Java 客户端访问,现在我正在努力让 netTcpBinding 正常工作。

您是否想让 netTcpBinding 与 java 客户端一起工作?因为,netTcpBinding only 适用于 .net 客户端。

NetTcpBinding 不是为互操作而设计的,它是为服务器和客户端都是 .net 时的性能而设计的

【讨论】:

  • 啊,是的,重新阅读听起来确实像是我在尝试这样做,不是吗。我正在开发 WCF 服务以供 .NET 应用程序(使用 netTcpBinding)和以其他编程语言开发的应用程序(使用 webHttpBinding)使用。谢谢你确认:)
猜你喜欢
  • 2010-10-08
  • 2011-06-15
  • 1970-01-01
  • 1970-01-01
  • 2011-07-23
  • 1970-01-01
  • 2011-01-04
  • 2011-02-21
  • 1970-01-01
相关资源
最近更新 更多