2014-03-13 57 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>