2013-02-26 58 views
3

我目前有一個Http Rest WCF4服務,由ServiceContract IEventService定義,它只通過HTTP公開。WCF Rest - 在一個ServiceContract中混合使用HTTP和HTTPS

我一直負責製作OperationContracts的一些僅通過HTTPS工作,所以我有分裂的那些方法爲一個單獨的ServiceContract叫IEventServiceHTTPS

在我的dev的盒子使用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> 

任何幫助將不勝感激,謝謝。

回答

1

我相信這個錯誤是由於IIS vdir [SSL設置] - >需要SSL - > true而產生的。如果您希望在同一服務中可訪問http和https端點,請取消選中此設置,因爲這會阻止您在vdir中執行不安全的http。

+2

這是**完全**錯在哪裏。非常感謝!奧利弗 – 2013-02-27 09:37:33