title: WCF How to send a List<T> as XML Request
body: <p>Fairly new to WCF, DataContracts and such here's is my first ever question on SO.</p>
  
  <p>The problem:
  I want to send an xml request to my WCF service.
  The request has the following layout;</p>
  
  <pre><code>&lt;DataContractName&gt;
    &lt;Other Stuff&gt;
     &lt;Blah&gt;&lt;/Blah&gt;
    &lt;/Other Stuff&gt;
    &lt;IdList&gt;
     &lt;Id&gt;1&lt;/Id&gt;
     &lt;Id&gt;2&lt;/Id&gt;
    &lt;IdList&gt;
  &lt;/DataContractName&gt;
  
  [DataContract(Name="DataContractName")]
  public sealed class Request
  {
     [DataMember]
     public List&lt;string&gt; IdList :get;set;}
  }
  </code></pre>
  
  <p>Running this request ends up ending with an empty list and thus not yielding the result I expected.
  Browsing the net and ending up mostly on Stackoverflow I found below links.
  However none of them seemed to have the right response for me.</p>
  
  <p><a href="https://stackoverflow.com/questions/8232595/how-to-send-list-of-objects-to-wcf-service?rq=1">How to send list of objects to WCF service?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3288883/how-to-pass-listobject-to-wcf">how to pass List&lt;Object&gt; to WCF</a></p>
  
  <p><a href="https://stackoverflow.com/questions/12028709/passing-listt-as-parameter-to-wcf-service-operation?rq=1">Passing List&lt;T&gt; as parameter to WCF service operation</a></p>
  
  <p>When I use the following lay-out, the request does work as expected.</p>
  
  <p>does work</p>
  
  <pre><code>&lt;DataContractName&gt;
    &lt;Other Stuff&gt;
      &lt;Blah&gt;&lt;/Blah&gt;
    &lt;/Other Stuff&gt;
    &lt;IdList xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"&gt;
      &lt;a:string&gt;1&lt;/a:string&gt;
      &lt;a:string&gt;2&lt;/a:string&gt;
    &lt;IdList&gt;
  &lt;/DataContractName&gt;
  </code></pre>
  
  <p>Obviously I want to be able to get rid of the namespace and string annotation for my list elements.
  Based on the information found in below links, it must be possible without the namespace annotation.</p>
  
  <p><a href="https://stackoverflow.com/questions/3557775/rest-ful-wcf-service-deserializing-c-sharp-list-of-strings-not-working-properly">REST-ful WCF service: Deserializing C# List of Strings not working properly</a>
     -->
   <a href="https://msdn.microsoft.com/en-us/library/aa347850.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/aa347850.aspx</a></p>
  
  <p>However I am not able to make it work.</p>
  
  <p>What I have done:
  Created a new CollectionDataContract;</p>
  
  <pre><code>[CollectionDataContract]
  public sealed class IdsList : Collection&lt;string&gt;
  {    
  }
  </code></pre>
  
  <p>and use it within my existing contract</p>
  
  <pre><code>[DataContract(Name="DataContractName")]
  public sealed class Request
  {
     [DataMember]
     public IdsList IdList {get;set;}
  }
  </code></pre>
  
  <p>However when I run this, the result is not what I expect (empty list again).</p>
  
  <p>So what can I do to create a valid request that my service will understand?</p>
  
  <p>OT: Why not just a simple &lt;code&gt; tag?</p>