title: WCF REST Self-Hosted 400 Bad Request
body: <p>I'm having a problem with a self-host WCF REST service.</p>
  
  <p>When I try to issue a GET via browser or Fiddler, I get a 400 Bad Request.  Tracing is reporting an inner exception of XmlException "The body of the message cannot be read because it is empty."</p>
  
  <p>I don't have any configuration in app.config (do I need any?).  I have tried changing WebServiceHost to ServiceHost, and WSDL is returned, but the operations still return 400.</p>
  
  <p>What am I missing here?</p>
  
  <pre><code>// Add Reference to System.ServiceModel and System.ServiceModel.Web
  using System;
  using System.Diagnostics;
  using System.ServiceModel;
  using System.ServiceModel.Description;
  using System.ServiceModel.Web;
  
  namespace WCFRESTTest
  {
      class Program
      {
          static void Main(string[] args)
          {
              var baseAddress = new Uri("http://localhost:8000/");
              var host = new WebServiceHost(typeof(RestService), baseAddress);
  
              try
              {
                  host.AddServiceEndpoint(typeof(IRestService), new WSHttpBinding(), "RestService");
  
                  var smb = new ServiceMetadataBehavior();
                  smb.HttpGetEnabled = true;
                  host.Description.Behaviors.Add(smb);
  
                  host.Open();
                  Console.WriteLine("Service Running.  Press any key to stop.");
                  Console.ReadKey();
              }
              catch(CommunicationException ce)
              {
                  host.Abort();
                  throw;
              }
          }
      }
  
      [ServiceContract]
      public interface IRestService
      {
          [OperationContract]
          [WebGet(UriTemplate = "Test")]
          bool Test();
      }
  
      [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
      public class RestService : IRestService
      {
          public bool Test()
          {
              Debug.WriteLine("Test Called.");
              return true;
          }
      }
  }
  </code></pre>