无法为net.tcp WCF服务添加服务客户端

时间:2014-03-03 11:51:12

标签: c# asp.net .net wcf tcp

我正在尝试为基于net.tcp的WCF服务添加客户端。当我使用“添加服务引用”并提供此URL: net.tcp://localhost/service1.svc 时,会出现以下错误。

  

无法识别URI前缀。元数据包含一个引用   无法解决:'net.tcp://localhost/service1.svc'。不能   连接到net.tcp://localhost/service1.svc。连接尝试   持续了00:00:02.0051147的时间跨度。 TCP错误代码10061:否   可以建立连接,因为目标机器主动拒绝   它127.0.0.1:808。由于目标,无法建立连接   机器主动拒绝它127.0.0.1:808如果服务定义在   当前的解决方案,尝试构建解决方案并添加服务   再次参考。

我检查了Windows组件的WCF非http服务,但它们已经安装。这很简单:

Enabling non-http protocols for WCF services

如您所见,它们是为.NET 3.5.1安装的,而我的服务是在.NET 4.5中构建的。这是问题吗?我该如何解决呢?因为Windows组件列表中没有.NET 4.5的选项。

以下是我的WCF服务的配置:

<system.serviceModel>
<services>
<service name="CoreService.Service1" behaviorConfiguration="beh1">
  <host>
    <baseAddresses>
      <add baseAddress="net.tcp://localhost/Service1.svc"/>
    </baseAddresses>
  </host>
        <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IAccountService"/>
       <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.ICategoryService"/>
         <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.ICommonService"/>
         <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IFollowerService"/>
         <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IInterestService"/>
<endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IInviteService"/>

  <endpoint
          address="mex"
          binding="mexTcpBinding"
          contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="ultra"
     maxBufferPoolSize="2147483647"
     maxBufferSize="2147483647"
     maxConnections="2147483647"
     maxReceivedMessageSize="2147483647"
     portSharingEnabled="false"
     transactionFlow="false"
     listenBacklog="2147483647"
     sendTimeout="00:01:00">
<security mode="None">
<message clientCredentialType="None"/>
<transport protectionLevel="None" clientCredentialType="None"/>
</security>
<reliableSession enabled="false"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
    <serviceBehaviors>
      <behavior name="beh1">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="True" />
        <dataContractSerializer maxItemsInObjectGraph="65536" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

1 个答案:

答案 0 :(得分:1)

WCF HTTP或非HTTP激活功能与您的服务之间似乎不兼容。

据我所知,IIS中的配置缺失或错误,这可以解释被拒绝的连接。要使用net.tcp正确配置IIS,请查看here