使WCF Restful 向外提供https服務

1.先建一個WCF向外提供的Restful風格的服務項目(這裏不是本文重點,在此不詳述)web

2.安裝IIS,導入安全證書,並讓項目綁定到https安全

3.配置web.configcode

 3.1 在system.ServiceModel節點中添加以下節點xml

<bindings>
      <webHttpBinding >
        <binding name="SecureWebBinding" >
            <security mode="Transport">
              <transport clientCredentialType="None"></transport>
            </security>
        </binding>
      </webHttpBinding>
     </bindings>

上面注意 security 的 mode =「Transport」 而非 「None」it

3.2 而後在services節點中添加以下節點io

<!-- https start-->
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="SecureWebBinding"
         contract="HeatNetworkMobileWcfService.IService"  />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        <!-- https end-->

最終修改部分以下class

到此爲止配置搞定cli

相關文章
相關標籤/搜索