我已经开辟了数十个博客和SO问题但仍无法实现这一目标。我可以通过HTTP加载我的服务,但是我通过HTTPS收到以下错误:
找不到与绑定secureWeb的端点的scheme http匹配的基址。注册的基地址方案是[https]。
我在IIS下本地托管在SSL网站下,该网站已经适用于其他几个应用程序。这是我想要工作的配置;任何建议将不胜感激!
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="secureWeb">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" httpHelpPageEnabled="false" httpsHelpPageEnabled="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Example.TestService">
<endpoint binding="webHttpBinding" bindingName="secureWeb" bindingNamespace="http://example.com/services"
behaviorConfiguration="webBehavior"
contract="Example.ITestService" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="Test.svc" service="Example.TestService" factory="Example.Common.ServiceModel.Activation.FlatWsdlServiceHostFactory" />
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
答案 0 :(得分:1)
基于对WCF配置的审核,我认为该问题可能与服务元数据配置有关。配置似乎指定元数据可通过http和https获得,但端点仅包含安全https(secureWeb)的绑定。
在以下行中,将httpGetEnabled值从true更改为false。
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
注意:Creating a WCF RESTful Service And Secure It Using HTTPS Over SSL博文提到最后更改服务元数据选项:
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
最后,我们需要更新要使用的元数据发布端点 HTTPS也是如此:
答案 1 :(得分:1)
除了已经说过的其他内容之外,我认为您应该bindingConfiguration="secureWeb"
代替bindingName="secureWeb"
(例如<endpoint binding="webHttpBinding" bindingConfiguration="secureWeb"...
)