0

我一直在为所有这些使用 http,当我使用 net.tcp 并添加引用时,我收到一个错误,例如

找不到与具有绑定 NetTcpBinding 的终结点的方案 net.tcp 匹配的基地址。注册的基地址方案是 [http]。

我的 web.config

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="servicebehave" name="WcfServ.Service1">
        <endpoint address="" binding="netTcpBinding" 
          bindingConfiguration="" name="nettcp" contract="WcfServ.IService1" />

        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          name="mex" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:51560/Service1.svc" />
           <add baseAddress="http://localhost:8080/Service1.svc"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="netTcpBinding">
          <security mode="Transport" />
        </binding>
      </netTcpBinding>

    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="servicebehave">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>

        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

谁能告诉我我做错了什么?

4

2 回答 2

1

您不能在 IIS 6 下托管 net.tcp,它仅支持 HTTP(s)。因此,您只能使用 HTTP 绑定(基本、ws 或 2007)。为了提供 net.tcp 和其他协议,需要 WAS。您可以单独激活它,但我建议您将它与 IIS 7 一起安装(它作为它的一部分安装),因为 IIS 7 还提供了一个方便的服务管理平台。

另一种解决方案是使用支持 tcp 协议的 ServiceHost 类实例更改托管环境以使其自托管或服务托管。

于 2013-09-02T14:44:41.870 回答
0

如果您想在IIS 7中为 net.tcp 配置 wcf 服务,请参考以下答案:

WCF 服务基地址 Http 和 netTcp

问候

于 2014-07-24T16:58:32.180 回答