【问题标题】:Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Base address schemes are [http]找不到与具有绑定 NetTcpBinding 的端点的方案 net.tcp 匹配的基地址。基地址方案是 [http]
【发布时间】:2020-06-02 07:52:45
【问题描述】:

我的 WCF 服务具有此配置,该服务在 IIS Express 端口号 50187 上运行。该服务托管在 Visual Studio 2017 的 IIS Express 上:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="QCConsumerBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="50000000" maxBufferPoolSize="5242880" maxReceivedMessageSize="50000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="QCWCFService.QCService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="QCConsumerBinding" contract="QCWCFService.IQCService" />
      </service>
      <service name="QCWCFService.QCFinalService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="QCConsumerBinding" contract="QCWCFService.IQCFinalService" />
      </service>

      <service name="QCWCFService.CalibrationService">
        <endpoint address="service" binding="netTcpBinding" contract="QCWCFService.ICalibrationService" />
        <endpoint address="" binding="wsDualHttpBinding" contract="QCWCFService.ICalibrationService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8080/CalibrationService" />
            <add baseAddress="http://localhost:8081/CalibrationService" />
          </baseAddresses>

        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>          
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- 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="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add scheme="http" binding="wsDualHttpBinding" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

但是当我尝试运行该服务时,它给出了这个异常:

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].

虽然我有另一个具有相同配置的双 Http 绑定的应用程序,但效果很好

【问题讨论】:

    标签: c# wcf wcf-binding


    【解决方案1】:

    默认情况下,IIS express 不支持Net.tcp 协议。 带有Nettcpbinding 的服务端点需要一个基于NetTcp 协议的基地址。

    <endpoint address="service" binding="netTcpBinding" contract="QCWCFService.ICalibrationService" />
    

    虽然我们使用Host Section 提供了Nettcp 基地址,但它不起作用。这是因为 IIS express 使用自配置来提供基​​地址来运行当前项目。 IIS express的配置通常位于当前解决方案的.vs文件夹中,名为applicationhost.config

    如果我们在具有此配置的控制台应用程序中运行此项目,它将起作用。因此,我们应该为 Nettcp 协议提供一个基地址。这可以在 IIS 中完成。
    1.启用net.tcp协议的windows功能。

    2.网站添加Net.tcp支持

    3.在site binding module中添加net.tcp协议。

    net.tcp协议添加到网站的详细信息请参考下文。
    WCF ContractFilter Mismatch when enabling Reliable Session
    如果问题仍然存在,请随时告诉我。

    【讨论】:

    • 非常感谢,它成功了。但是为什么我的其他具有类似配置的项目正在 IIS Express 上运行?
    • 也许我应该搜索如何在 IIS Express 上启用 nettcp 协议。无论如何,该服务在 IIS 上工作。非常感谢。你节省了我的时间。
    • 上网一搜,发现IIS express不支持Nettcp协议。您可以使用 Nettcp 地址使用该服务吗?这表明它是否适用于 Net.tcp。 stackoverflow.com/questions/15838792/…
    • 我的错。我无法使用该服务。它只适用于 IIS。
    • 没关系,祝你有美好的一天。
    猜你喜欢
    • 1970-01-01
    • 2017-08-13
    • 1970-01-01
    • 2012-04-06
    • 2015-07-21
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多