WCF: Configuring HTTP / HTTPS to host a System.ServiceModel WCF Service

Using Windows Communication Foundation (WCF) over HTTP either requires the use of a host, such as Internet Information Services (IIS), or manual configuration of the HTTP settings through the HTTP Server API. This post describes how to manually configure WCF when using HTTP and HTTPS. Logo_WCF

The tool used to configure HTTP settings depends on the operating system the computer is running.

When running Windows Server 2003 or Windows XP, use the HttpCfg.exe tool. With Windows Server 2003 this tool is installed. With Windows XP, you can download the tool at Windows XP Service Pack 2 Support Tools. For more information, see Httpcfg Overview.

With Windows Vista, you configure these settings with the Netsh.exe tool.

However, before you try running a Console Application or Windows Service application that hosts a WCF service with basicHttpBinding or wsHttpBinding, see this MSDN article about "Configuring HTTP and HTTPS". If you are WAS-hosted or Web App-hosted, the urlacl entries are made on your behalf.

You can view the current entries with "netsh http show urlacl". To make the changes, you’ll need to "Run as Administrator" when going into your Command Prompt.

I decided to use the following command:

netsh http add urlacl url=http://+:8080/ user=\Everyone

You should adjust the ports and/or path as necessary for your situation:

netsh http add urlacl url=http://+:8080/MyConsoleAppHostedService user=DOMAIN\user netsh http add urlacl url=http://+:8091/MyWindowsServiceHostedService user=\SYSTEM

to delete an urlacl do:

delete urlacl url=https://*:8172/

Links

Configuring HTTP and HTTPS on Microsoft MSDN

Netsh Commands for Hypertext Transfer Protocol on Microsoft Technet

Leave a Reply

Your email address will not be published. Required fields are marked *