In this article, I will explain how we can expose a WCF REST Service over secure HTPP (HTTPS)? Essentially there are three steps involved.
using System;using System.ServiceModel;using System.ServiceModel.Web;using WcfService13;using System.Diagnostics;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { WebServiceHost host = new WebServiceHost(typeof(Service1)); string uri = "https://localhost:443/Service1.svc/"; WebHttpBinding binding = new WebHttpBinding(); binding.Security.Mode = WebHttpSecurityMode.Transport; host.AddServiceEndpoint(typeof(IService1), binding, uri); host.Open(); Console.WriteLine("REST Service with HTTPS is running "); Process.Start(uri); Console.ReadKey(true); } }}Running ServiceNow when we run the console application the browser will be started automatically.
If you notice the URL, you will see that the service is running on SSL over HTTP. The URL is starting with HTTPS. In the next article, I will show you calling WCF REST Service over HTTPS from a client. Thanks for reading.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: