2013-04-03 166 views
0

我正在構建WCF Restful Web服務,目前我通過http傳輸數據。現在,我想通過https安全地傳輸數據。我應該在我的配置文件中更改什麼來啓用此功能?這是我目前的配置文件:通過SSL配置REST WCF服務

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="MyService.DBService" behaviorConfiguration="ServiceBehaviour"> 
     <endpoint address ="" binding="webHttpBinding" contract="MyService.IDBService" behaviorConfiguration="web"> 
     </endpoint> 
     </service> 
    </services> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehaviour"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

回答

0

你必須定義一個定製的配置傳輸層安全性和使用bindingConfiguration是指,在您的端點。請檢查this瞭解有關配置安全性的信息。一旦你有這個在您的IIS配置一個SSL證書來完成這一點。您可以參考this以瞭解如何使用IIS配置SSL證書。

+0

是否有可能跳過IIS?現在我在我的服務器上託管WCF服務 – user1135357

+0

對於selfhost,您將不得不使用netsh直接使用HTTP.Sys配置您的SSL證書。您可以參考這篇文章,瞭解如何使用selfhost配置SSL。 http://www.codeproject.com/Articles/24027/SSL-with-Self-hosted-WCF-Service – Praburaj