title: Can a WebServiceHost be changed to avoid the use of HttpListener?
body: <p>I am looking for a way to use a WCF WebServiceHost without having to rely on the HttpListener class and it's associated permission problems (see <a href="https://stackoverflow.com/questions/280690/alternative-to-httplistener">this question</a> for details).</p>
  
  <p>I'm working on a application which communicates locally with another (third-party) application via their REST API. </p>
  
  <p>At the moment we are using WCF as an embedded HTTP server. We create a WebServiceHost as follows:</p>
  
  <pre><code>String hostPath = "http://localhost:" + portNo;
  WebServiceHost host = new WebServiceHost(typeof(IntegrationService), new Uri(hostPath));
  
  // create a webhttpbinding for rest/pox and enable cookie support for session management
  WebHttpBinding webHttpBinding = new WebHttpBinding();
  webHttpBinding.AllowCookies = true;
  
  ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IIntegrationService), webHttpBinding, "");
  
  host.Open()
  
  ChannelFactory&lt;IIntegrationService&gt; cf = new ChannelFactory&lt;IIntegrationService&gt;(webHttpBinding, hostPath);
  IIntegrationService channel = cf.CreateChannel();
  </code></pre>
  
  <p>Everything works nicely as long as our application is run as administrator. If we run our application on a machine without administrative privileges the host.Open() will throw an HttpListenerException with ErrorCode == 5 (ERROR_ACCESS_DENIED).</p>
  
  <p>We can get around the problem by running httpcfg.exe from the command line but this is a one-click desktop application and that's not really as long term solution for us.</p>
  
  <p>We could ditch WCF and write our own HTTP server but I'd like to avoid that if possible. </p>
  
  <p>What's the easiest way to replace HttpListener with a standard TCP socket while still using all of the remaining HTTP scaffolding that WCF provides?</p>