【问题标题】:WCF Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBindingWCF 找不到与绑定 MetadataExchangeHttpBinding 的终结点的方案 http 匹配的基地址
【发布时间】:2014-09-29 22:24:01
【问题描述】:

我正在尝试让 wcf 服务在 Windows 服务主机中运行。我目前 收到错误“找不到与绑定 MetadataExchangeHttpBinding 的端点的方案 http 匹配的基地址。注册的基地址方案是 [net.tcp]。”

我正在使用 .Net Framework 4.5

我正在尝试获取 tcp.net 二进制服务。任何帮助表示赞赏。我拥有的跟踪文件 created 没有帮助。这是我的 [REVISED] app.config:

<?xml version="1.0" encoding="utf-8" ?>
<!-- IMPORTANT!  To run this on your local machine, first follow instructions in http://support2.microsoft.com/kb/2785590 -->
<!-- You will run into tcp listen errors otherwise -->
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>


  <system.serviceModel>
    <services>
      <service name="SettingsDB.Configuration" behaviorConfiguration="DefaultBehavior">
        <endpoint binding="netTcpBinding" bindingConfiguration="max" contract="SettingsDB.IConfiguration" address="Settings" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9000/SettingsService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="max" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" listenBacklog="2147483647" transactionFlow="false" portSharingEnabled="true">
          <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
          <reliableSession enabled="false" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceMetadata httpGetEnabled="false" httpGetUrl="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <runtime>
    <gcServer enabled="true" />
  </runtime>
</configuration>

【问题讨论】:

    标签: c# windows wcf service


    【解决方案1】:

    你可以试试:

    <service name="SettingsDB.Settings">
    

    为行为添加名称并将httpGetUrl 更改为简单的true

    <behavior>
      <serviceMetadata httpGetEnabled="true" 
                       httpGetUrl="true"     />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    

    【讨论】:

    • 我现在收到错误“在服务配置实现的合同列表中找不到合同名称'IMetadataExchange'。将 ServiceMetadataBehavior 添加到配置文件或直接添加到 ServiceHost启用对此合同的支持。”
    • 对不起,我已经更新了我的答案。在服务中有双重名称。它应该像上面那样工作(至少对我来说适用于类似的设置)
    • 谢谢,它让我朝着正确的方向前进。现在我只需要弄清楚如何使用这个服务:)
    猜你喜欢
    • 1970-01-01
    • 2012-05-04
    • 2021-06-02
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    • 2013-11-23
    • 2020-06-02
    相关资源
    最近更新 更多