title: WCF restful WebMessageFormat.Json
body: <p>I have  a problem. Here simple WCF restful service and he doesn't want to response with JSON format although I specify <code>ResponseFormat = WebMessageFormat.Json</code>. He always responses with XMLformat: <code>xmlns="http://schemas.datacontract.org/2004/07/GoalTracker.WcfRestService"</code></p>
  
  <pre><code>public class Global : HttpApplication
  {
      void Application_Start(object sender, EventArgs e)
      {
          Database.SetInitializer&lt;GoalTrackerDb&gt;(new GoalTrackerInitializer());
          RegisterRoutes();
      }
  
      private void RegisterRoutes()
      {
          RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(Service1)));
      }
  }    
  
  [ServiceContract]
  public interface IService1
  {
      [OperationContract]
      [WebInvoke(UriTemplate = "TestPatient",
          ResponseFormat = WebMessageFormat.Json,
          Method = "GET")]
      List&lt;Patient&gt; GetCollection();
  
      [OperationContract]
      [WebInvoke(UriTemplate = "TestPatient/{id}",
          ResponseFormat = WebMessageFormat.Json,
          Method = "GET")]
      TestPatient Get(string id);
  }
  
  
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
  public class Service1 : IService1
  {
          GoalTrackerDb db = new GoalTrackerDb();
          public List&lt;Patient&gt; GetCollection()
          {
              var result = db.Patients.ToList();
              return result;
          }
          public TestPatient Get(string id)
          {
              TestPatient testpat = new TestPatient();
              return testpat;
          }
    }
  
  public class TestPatient
  {
  
      public long ID { get; set; }
  
      public string Email { get; set; }
  
      public string FirstName { get; set; }
  
      public string LastName { get; set; }
  
      public ICollection&lt;TestGoal&gt; Goals { get; set; }
  
      public TestPatient()
      {
          ID = 0;
          Email = "ads@mail.com";
          FirstName = "janmbo";
          LastName = "Ayo";
          Goals = new Collection&lt;TestGoal&gt;();
          Goals.Add(new TestGoal());
          Goals.Add(new TestGoal());
      }
  }
  
  
  public class TestGoal
  {
  
      public long ID { get; set; }
  
      public string GoalName { get; set; }
  
      public TestGoal()
      {
          ID = 2;
          GoalName = "SomeGoalName";
      }
  }
  </code></pre>