locked
使用TCP协议的服务,客户端add service reference失败 RRS feed

  • 问题

  • 使用了nettcp绑定,服务启动以后,客户端试图add service reference一直失败,显示以下错误:

    元数据包含无法解析的引用:“net.tcp://127.0.0.1:5353/”。
    无法连接到 net.tcp://127.0.0.1:5353/。连接尝试持续了 00:00:00.0312500 时间跨度。TCP 错误代码 10045: 参考的对象类型不支持尝试的操作。。
    参考的对象类型不支持尝试的操作。


    以下是我服务器端的配置文件,不知道哪里出了问题?换成wsHttp绑定,就一切正常了。



    <services>
          <service name="ServerPart.Server" behaviorConfiguration="sb">
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://127.0.0.1:5353" />
              </baseAddresses>
            </host>
            <endpoint address="net" binding="netTcpBinding"  contract="ServerPart.IServer" />
            <endpoint address="mex"  name="net.tcp" binding="netTcpBinding" bindingConfiguration="mexTcp" contract="IMetadataExchange" />
          </service>
        </services>
        <bindings>
          <netTcpBinding>
              <binding name="mexTcp" >
                   <security mode="None"/>
              </binding>
          </netTcpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="sb">
              <serviceMetadata  />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
    they say nothing last forever
    2009年8月24日 16:47

答案

  • Hi,
      你元数据终结点配置错误。
    你修改一下,参考这个。
       1.    <endpoint address="mex"  name="net.tcp" binding="netTcpBinding" bindingConfiguration="mexTcp" contract="IMetadataExchange" />

    ---><endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />

     你的绑定不对:netTcpBinding,应该修改为元数据专用的Tcp绑定:mexTcpBinding。
      2.  这个配置其实也不起作用bindingConfiguration="mexTcp" ,你不是针对mexTcpBinding的绑定属性配置。

      呵呵,修改以后在调试一下~.
      你是尤文图斯的球迷呵呵。

    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
    欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
    欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
    欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum
    2009年8月25日 0:54
    版主

全部回复

  • Hi,
      你元数据终结点配置错误。
    你修改一下,参考这个。
       1.    <endpoint address="mex"  name="net.tcp" binding="netTcpBinding" bindingConfiguration="mexTcp" contract="IMetadataExchange" />

    ---><endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />

     你的绑定不对:netTcpBinding,应该修改为元数据专用的Tcp绑定:mexTcpBinding。
      2.  这个配置其实也不起作用bindingConfiguration="mexTcp" ,你不是针对mexTcpBinding的绑定属性配置。

      呵呵,修改以后在调试一下~.
      你是尤文图斯的球迷呵呵。

    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
    欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
    欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
    欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum
    2009年8月25日 0:54
    版主
  • 感谢答复,我现在发现这个mex的endpoint完全可以不是tcpbinding,而是wshttpbinding,也就是用tcp绑定发布服务,而用http绑定暴露metadata,这样客户端add service reference 就没有问题了。


    they say nothing last forever
    2009年8月30日 15:07