Click here to Skip to main content
15,885,757 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 94K   5.2K   40  
A guide for creating a self hosted WCF SOAP Service over HTTPS.
using System;
using System.ServiceModel;
using System.ServiceProcess;
using WCFOverHttps.WCFHost;

namespace WCFOverHttps
{
    public partial class WcfOverHttpsService : ServiceBase
    {
        private ServiceHost m_host;

        public WcfOverHttpsService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            StartWcfService();
        }

        protected override void OnStop()
        {
            try
            {
                if (m_host != null)
                {
                    m_host.Close();
                    m_host = null;
                }
            }
            catch(Exception ex)
            {
                //handle exception
            }
        }

        private void StartWcfService()
        {
            m_host = new ServiceHost(typeof(WcfService));
            m_host.Open();
        }
    }
}

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