WCF异常:找不到与端点的scheme http匹配的基址

Rea*_*oka 20 c# wcf web-services

我正在尝试在IIS中的单独网站上托管WCF Web服务,其中https为443作为唯一绑定.

当我在使用绑定(http(80)/ https(443))的网站中使用它时,以下配置很有效.如果我删除http绑定,它会开始抛出以下错误.

无法通过绑定BasicHttpBinding找到与端点的scheme http匹配的基址.注册的基地址方案是[https].

如何在仅具有https绑定的IIS网站中使其工作?

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="defaultBasicHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="Certificate" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/ERPService/retailPayment.svc"
                binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding"
                contract="RetailPaymentService.RetailPayment.SVRetailPaymentService" name="EnterpriseRetailPayment" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="MyEndPointBehavior">
          <!--<SchemaValidator enabled="true"/>-->
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service name="SettlementSalesCollection.SaleItemService" behaviorConfiguration="MyServiceTypeBehaviors">
        <endpoint behaviorConfiguration="MyEndPointBehavior" binding="basicHttpBinding"
                  name="SettlementSalesCollection"
                  contract="SettlementSalesCollection.CITransactionSettlementListenerService" />
        <endpoint name="mexEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
      </service>
    </services>
    <extensions>
      <behaviorExtensions>
        <add name="SchemaValidator"
             type="SettlementSalesCollection.SchemaValidation.SchemaValidationBehavior+CustomBehaviorSection, SettlementSalesCollectionService, Version=1.0.0.0, Culture=neutral" />
      </behaviorExtensions>
    </extensions>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

Szy*_*mon 19

您的配置应该与此类似.您可能<transport clientCredentialType="None" proxyCredentialType="None" />需要根据身份验证的需要进行更改.以下配置不需要任何身份验证.

<bindings>
    <basicHttpBinding>
        <binding name="basicHttpBindingConfiguration">
            <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None" />
            </security>
        </binding>       
    </basicHttpBinding>
</bindings>

<services>
    <service name="XXX">
        <endpoint
            name="AAA"
            address=""
            binding="basicHttpBinding"
            bindingConfiguration="basicHttpBindingConfiguration"
            contract="YourContract" />
    </service>
<services>
Run Code Online (Sandbox Code Playgroud)

这将允许WCF服务basicHttpBinding使用HTTPS.


小智 8

我的问题是由IIS中缺少绑定引起的:右键单击站点>编辑绑定>添加> https

选择"IIS Express开发证书"并将端口设置为443然后我添加了另一个绑定到webconfig:

<endpoint address="wsHttps" binding="wsHttpBinding" bindingConfiguration="DefaultWsHttpBinding" name="Your.bindingname" contract="Your.contract" />

还添加到serviceBehaviours: <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />

最终它工作,我在stackoverflow上检查此错误的解决方案都没有适用于我的特定场景,因此包括在这里,以防它帮助其他人

  • 这是我遇到的问题.我的配置包含HTTP和HTTPS的绑定.我发现默认IIS网站不包含HTTPS绑定.如果您的配置包含HTTP和HTTPS的端点,则需要添加它. (2认同)

小智 8

在我的情况下,这解决了问题

  1. 通过单击项目名称上的 F4 转到项目属性
  2. 设置 SSLEnabled = true

项目属性图片


Sim*_*ver 7

如果仅https在IIS中配置为站点绑定,则可以获得此项.

你需要添加http(80)以及https(443)- 至少我做了:-)