title: the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'
body: <p>When using firebug, I got this wired error "NetworkError: 415 Cannot process the ...xt/xml; charset=utf-8'. - <code>http://localhost:59899/wsccc1/wscccService.svc/RunTts</code>" in my asp.net mvc 4 project.</p>
  
  <p>The code:</p>
  
  <pre><code>&lt;script lang="javascript" type="text/javascript"&gt;
      function ttsFunction() {
          serviceUrl = "http://localhost:59899/wsccc1/wscccService.svc/RunTts";
          var data = new Object();
          data.text = $('#speak').val();
          var jsonString = JSON.stringify(data);
          $.ajax({
              type: 'POST',
              url: serviceUrl,
              data: jsonString,
              contentType: 'application/json; charset=utf-8',
              dataType: 'json',
              success: function() { alert('ok')},
              error: function (xhr,status,error) {
                  console.log("Status: " + status);
                  console.log("Error: " + error);
                  console.log("xhr: " + xhr.readyState);
              },
              statusCode: {
                  404: function() {
                      console.log('page not found');
                  }
              }
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>The service code:</p>
  
  <pre><code> [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
  public class wservice:Iwservice
  {
      public string RunTts(string value)
      {
          return value.ToUpper();
      }
  }
  </code></pre>
  
  <p>The interface is:</p>
  
  <pre><code>namespace service
  {
       [ServiceContract]
       public interface Iwservice
       {
          [OperationContract]
          [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "RunTts")]
          string RunTts(string text);
       }
  }
  </code></pre>
  
  <p>And web config, I used file-less in WCF.:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5"/&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;serviceHostingEnvironment &gt;
         &lt;serviceActivations&gt;
           &lt;add factory="System.ServiceModel.Activation.ServiceHostFactory" 
       relativeAddress="./wsccc1/wscccService.svc" 
       service="service.wservice"/&gt;
        &lt;/serviceActivations&gt;
      &lt;/serviceHostingEnvironment&gt;
     &lt;behaviors&gt;
       &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
          &lt;/behavior&gt;
       &lt;/serviceBehaviors&gt;
     &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt; 
  </code></pre>