【发布时间】:2013-02-26 14:50:56
【问题描述】:
我目前有一个 Http Rest WCF4 服务,由 ServiceContract IEventService 定义,该服务仅通过 HTTP 公开。
我的任务是让 一些 OperationContracts 只能通过 HTTPS 工作,所以我将这些方法拆分为一个单独的 ServiceContract,称为 IEventServiceHTTPS
使用带有自签名证书的 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>
任何帮助将不胜感激,谢谢。
【问题讨论】:
标签: wcf http ssl https webhttpbinding