我目前有一个由ServiceContract IEventService
定义的Http Rest WCF4服务,该服务仅通过HTTP公开。
我的任务是使一些的OperationContracts只能通过HTTPS工作所以我将这些方法拆分为一个名为IEventServiceHTTPS
的单独ServiceContract
使用带有自签名证书的IIS7.5在我的开发箱上托管此文件,IEventServiceHTTPS
中的方法可以通过HTTPS调用,而不是通过HTTP调用,如预期的那样。
然而,IEventService
公开的HTTP方法现在不起作用。
尝试访问HTTP方法时,我得到以下信息:
HTTP Error 403.4 - Forbidden
The page you are trying to access is secured with Secure Sockets Layer (SSL).
带有我的更改的web.config:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">
<serviceActivations>
<add service="Api.EventService" relativeAddress="EventService.svc" factory="Api.UnityServiceHostFactory"/>
</serviceActivations>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="Api.EventServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Api.EventServiceBehavior" name="Api.EventService">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" bindingConfiguration="webBindingHTTP" contract="Api.IEventService"/>
**<endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" bindingConfiguration="webBindingHTTPS" contract="Api.IEventServiceHTTPS"/>**
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBindingHTTP">
<security mode="None"></security>
</binding>
**<binding name="webBindingHTTPS">
<security mode="Transport">
</security>
</binding>**
</webHttpBinding>
</bindings>
</system.serviceModel>
非常感谢任何帮助,谢谢。
答案 0 :(得分:1)
我认为此错误源于IIS vdir [SSL设置] - &gt;需要SSL - &gt;真正。如果您希望在同一服务中访问http和https端点,则取消选中此设置,因为这将阻止您在vdir中执行不安全的http。