【发布时间】:2013-11-23 22:54:54
【问题描述】:
我正在尝试在 IIS 中的单独网站上托管 WCF Web 服务,并将 443 处的 https 作为唯一绑定。
当我在同时使用两种绑定 (http(80) / https(443)) 的网站中使用以下配置时,它运行良好。如果我删除 http 绑定,它会开始抛出以下错误。
找不到与绑定 BasicHttpBinding 的端点的方案 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>
【问题讨论】:
-
将您的客户端端点更改为 https?例如
endpoint address="https://localhost/ERPService/retailPayment.svc -
那是这个服务使用的另一个服务。它以 http 运行。我刚刚发布了完整的
配置部分 -
也许将
<add binding="basicHttpBinding" scheme="http" />添加到<protocolMapping>部分?这是 WCF 的默认设置(所以它应该存在,除非你从另一个配置文件继承),但它可能值得一试。
标签: c# wcf web-services