Click here to Skip to main content
15,892,746 members
Articles / Programming Languages / C#

WCF self hosted service over HTTPS

Rate me:
Please Sign up or sign in to vote.
4.71/5 (10 votes)
26 Nov 2010CPOL2 min read 94.1K   5.2K   40  
A guide for creating a self hosted WCF SOAP Service over HTTPS.
using System;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.ServiceProcess;


namespace WCFOverHttps
{
    [RunInstaller(true)]
    public partial class WcfOverHttpsServiceInstaller : Installer
    {
        public WcfOverHttpsServiceInstaller()
        {
            InitializeComponent();

            Installers.Add(GetServiceInstaller());
            Installers.Add(GetServiceProcessInstaller());
        }

        public WcfOverHttpsServiceInstaller(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        private static ServiceInstaller GetServiceInstaller()
        {
            Process pc = Process.GetCurrentProcess();
            Directory.SetCurrentDirectory
            (pc.MainModule.FileName.Substring(0, pc.MainModule.FileName.LastIndexOf(@"\", StringComparison.CurrentCulture)
            ));

            ServiceInstaller installer = new ServiceInstaller
            {
                ServiceName = "WCF Over Https",
                Description = "WCF Over Https"
            };

            return installer;
        }

        private static ServiceProcessInstaller GetServiceProcessInstaller()
        {
            ServiceProcessInstaller installer = new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem };
            return installer;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Xrio
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions