【问题标题】:I am trying to host a WCF Service over two endpoints, http and https我正在尝试通过两个端点 http 和 https 托管 WCF 服务
【发布时间】:2015-02-24 13:49:12
【问题描述】:

我正在尝试通过 http 和 https 托管 WCF 服务并使用以下配置:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ITestService">
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpsBinding_ITestService">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" />
            <message />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="TestService" behaviorConfiguration="TestServiceBehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8081/"/>
            <add baseAddress="https://localhost:8083/"/>
          </baseAddresses>
        </host>
        <endpoint address=""
             binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService"
             contract="ITestService" name="BasicHttpsBinding_ITestService" />
        <endpoint address=""
             binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_ITestService"
             contract="ITestService" name="BasicHttpsBinding_ITestService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="TestServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

但我收到以下错误: 找不到与绑定 BasicHttpBinding 的终结点的方案 https 匹配的基地址。注册的基地址方案是 [http]。

需要一个解决方案,因为我已经为 http 和 https 定义了基地址和绑定。

谢谢。

【问题讨论】:

    标签: c# wcf http binding https


    【解决方案1】:

    试试这个

    <endpoint address=""
              binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpBinding_ITestService"
              contract="ITestService" name="BasicHttpsBinding_ITestService"/>
    <endpoint address=""
              binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpsBinding_ITestService"
              contract="ITestService" name="BasicHttpsBinding_ITestService"/>
     <endpoint address="mex" 
             binding="mexHttpsBinding" 
             contract="IMetadataExchange" />
    

    【讨论】:

    • MexExchangeHttpsBinding 出现相同错误:找不到与绑定 MetadataExchangeHttpsBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。
    • 尝试评论主机部分并检查我在开发过程中删除主机的情况
    【解决方案2】:

    我没有在 IIS 服务器上启用 https 绑定,并尝试使用 https 协议托管服务。在 IIS 服务器上创建证书并启用 https 绑定解决了该问题。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-02
      • 2011-02-11
      • 1970-01-01
      • 2018-04-02
      • 1970-01-01
      • 2012-02-23
      • 2015-02-06
      相关资源
      最近更新 更多