2014-03-13 51 views
0

我已經使用WCF構建了一個基於http的Web服務應用程序,並且一切正常。現在我嘗試將它轉換爲通過https運行,但我無法正常工作。我只收到「不良要求」。目前,此Web服務正在IIS 7.5和.NET 4.5上運行。任何人都知道我應該怎麼做才能將它從http轉換爲https,並且我將在客戶端更改以便能夠請求https Web服務而不是http。如何將wcf http web服務轉換爲https

Thx in advanced!

+0

http://social.msdn.microsoft.com/Forums/silverlight/en-US/f75fcdfd-4e2e-43d6-9654-5b858b41b5a5/conversion-of-wcf-to-https-from-http ?forum = silverlightweb And http://www.codeproject.com/Articles/36705/simple-steps-to-enable-HTTPS-on-WCF-WsHttp-bindi –

回答

0

對於服務配置使用此

<services> 
<service behaviorConfiguration="webServiceClientBehavior" name="My.Service.ServiceName"> 
     <endpoint address="http://localhost/WCFClient" binding="basicHttpBinding" bindingConfiguration="secureBinding" contract="My.Service.IServiceName"/> 
</service> 

對於綁定配置使用下面

<bindings> 
    <basicHttpBinding> 
    <binding name="secureBinding"> 
     <security mode="Transport" /> 
    </binding> 
    </basicHttpBinding> 

對於行爲的配置使用以下

<serviceBehaviors> 
    <behavior name="webServiceClientBehavior"> 
     <!--For MetaData--> 
     <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/WCFClientMD"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior>