WCF 无法找到 netTcpBinding

发布于 2024-11-27 23:57:52 字数 2475 浏览 3 评论 0原文

我正在尝试创建一个可通过 webHttpBinding 和 netTcpBinding 访问的 WCF 服务。我已经成功地通过 Java 客户端访问 webHttpBinding,现在我正在尝试让 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) 未找到。 如果当前解决方案中定义了该服务,请尝试构建该解决方案并再次添加服务引用。

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

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

感谢您提前提供的任何帮助。

I am trying to create a WCF service that is accessible through both webHttpBinding and netTcpBinding. I have been successful in getting the webHttpBinding to be accessible through a Java client and now I'm working on trying to get the netTcpBinding working.

I have set up the configuration like this;

<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>

In the same solution, I have a test application that I wish to connect to the netTcpBinding, I've right clicked on "Service References" and chosen "Add Service Reference...".
When I click on "Discover" it finds the service although says;

There was an error downloading 'http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service'.
There was no endpoint listening at http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.

But I am also unable to see the netTcpBinding in order for me to create a service reference to it.

I was wondering whether anyone can see what I am doing wrong as its probably something rather simple, but due to my lack of experience with WCF haven't noticed.

Thanks for any help in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一刻暧昧 2024-12-04 23:57:52

尝试将您的 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" />

Try changing your mex endpoint to this:

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

You were using your service's contract for the mex endpoint, which I don't believe will work.

You can set up a similar one for the NetTcpBinding:

<endpoint address="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net/mex"
          binding="mexTcpBinding"
          contract="IMetadataExchange" />
沙与沫 2024-12-04 23:57:52

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

您是否正在尝试让 netTcpBinding 与 java 客户端一起使用?因为,netTcpBinding 适用于 .net 客户端。

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

I have been successful in getting the webHttpBinding to be accessible through a Java client and now I'm working on trying to get the netTcpBinding working.

Are you trying to get the netTcpBinding to work with a java client ? Because, netTcpBinding only works with a .net client.

NetTcpBinding is not designed for interop, it's designed for performance when both the server and client are .net

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文