Exposing WCF REST and SOAP Service over HTTPS

Prabhat39
Posted by in WCF category on for Intermediate level | Points: 250 | Views : 4559 red flag

Expose WCF service through HTTPS for SOAP and REST

Introduction

In this article we come to know, how to expose REST and SOAP WCF service over HTTPS. We also come to know different SSL related settings in IIS.


Objective

To learn how to expose website or WCF Service over https and also how to use secure socket layer.


Explanation

To expose service over HTTPS you have do the following:-

1. Web.config file changes

2. IIS changes


Web.config file changes

1. In serviceMetaData change httpGetEnabled= true to httpsGetEnabled= true.

2. Set mexHttpBinding as mexHttpsBinding

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />

3. Set Binding for REST and SOAP

 <bindings>

      <webHttpBinding>

        <binding name="SecureWebBinding">

          <security mode="Transport"></security>

        </binding>

      </webHttpBinding>

      <basicHttpBinding>

        <binding name="SecureBasicBinding">

          <security mode="Transport"></security>

        </binding>

      </basicHttpBinding>

    </bindings>  

 

4. Set bindingConfiguration properties in endpoint.

        <endpoint  address="SOAP"

binding="basicHttpBinding"

contract="IService"

bindingConfiguration="SecureBasicBinding" />

        <endpoint  address="REST"

binding="webHttpBinding"

contract="IService "

bindingConfiguration="SecureWebBinding" />


IIS Changes

1. Create Server Certificate

In connections section select root node than double click on server certificate.


In right pane click on “Create Self-Singed Certificate”. Give certificate name and click on OK. One certificate is created.


2. Set certificate to HTTPS

Click on your web site and select bindings from right pane.

Click on Add and select type as “https” and select the SSL Certificate that you created.

Click on OK.


3. Now select SSL Settings of the web site. Check on “Require SSL”. From right pane click on Apply.


Restart you web site.

Your web site is ready to use over HTTPS.


Conclusion

So, in this article we have learned to expose WCF service over HTTPS we have to do some setting changes in web.config as well as in IIS.  Hope this will help you.



Page copy protected against web site content infringement by Copyscape

About the Author

Prabhat39
Full Name: Prabhat Kumar
Member Level:
Member Status: Member
Member Since: 12/21/2012 5:30:10 AM
Country: India
Regards, Prabhat Kumar
http://www.dotnetfunda.com
Prabhat is a programmer and having 5+ years of developing experience in IT field. Major strength are C#, WPF, asp.net and SQL server 2008. He is also having good exposure in WCF.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)