title: Sending array of objects to WCF
body: <p>In my application i want to save the data by using jQuery and Ajax.I have a WCF Service.
  I want to save a List of Objects by using ajax.I have tried with following code, but it
  is not working.</p>
  
  <p><strong>jquery code :</strong></p>
  
  <blockquote>
  <pre><code>      var listOfObjects=new Array();
  </code></pre>
  </blockquote>
  
  <pre><code>      //creating list of objects
        for(var i=0;i&lt;5;i++)
         {   var MyEntity=new Object();
             MyEntity.TestId =i;
             MyEntity.TestId =i+"testName";
             listOfObjects.push(MyEntity);
         }
  
          //Saving info
          $.ajax({
              type: "POST",
              async: false,
              data: JSON.stringify(listOfObjects),
              url: "../ServiceLayer/myService.svc/SaveResults",
              contentType: "application/json; charset=utf-8",
              dataType: "json",          
              success: function () {
                  alert("success");
              },
              error: function () {
                  alert("Error");
              }
          });
  </code></pre>
  
  <p><strong>WCF :</strong></p>
  
  <pre><code>    [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,
       ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
      public void SaveLabResults(List&lt;MyEntity&gt; myEntity)
      {
            var lstEntities=myEntity;
      }
  </code></pre>
  
  <p><strong>Entity:</strong></p>
  
  <pre><code>[DataContract]
  public class MyEntity
  {
      [DataMember]
      public string TestId { get; set; }
      [DataMember]
      public string TestName { get; set; }
  }
  </code></pre>
  
  <p>In this way i am trying to send the list data.But internal server error is coming.I am not getting where actually i am wrong.Is there any other way to send the list of objects to WCF ?</p>
  
  <p>Thanks</p>