title: XML Deserializer / XSD tool / object arrays
body: <p>I have an XSD, and used the xsd.exe tool to create c# classes. In a webservice I am accepting in the MessageContract an instance of one of these created objects.</p>
  
  <p>The relevant portion of the xsd to this question is here:</p>
  
  <pre><code>&lt;xs:element name="Tasks"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element ref="Task" maxOccurs="unbounded"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="Task"&gt; ... &lt;/xs:element&gt;
  </code></pre>
  
  <p>The xsd created this:</p>
  
  <pre><code>/// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
  public partial class Tasks {
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute("Task")]
      public Task[] Task;
  }
  
  /// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
  public partial class Task { ... }
  </code></pre>
  
  <p>SOAPUI created a soap request from the WSDL that looks like this:</p>
  
  <pre><code>&lt;Tasks&gt;
    &lt;Task&gt;
      &lt;Task&gt;
        .. task data here
      &lt;/Task&gt;
    &lt;/Task&gt;
  &lt;/Tasks&gt;
  </code></pre>
  
  <p>note the extra  wrapper element. When trying to run that soap request, I get a deserialization error: Error in line x position y: 'Element' 'WWW' from namespace 'ZZZ' is not expected. Expecting element 'SSS'</p>
  
  <p>After finding the extraneous  node in the generated SOAP request, I made my new request look as such:</p>
  
  <pre><code>&lt;Tasks&gt;
    &lt;Task&gt;
      ...task data here
    &lt;/Task&gt;
  &lt;/Task&gt;
  </code></pre>
  
  <p>Now the deserializer 'works', but in my method the Tasks object contains an empty Task array.</p>
  
  <p>So my question is: Why is the automated request generator creating the wrapper Task object, and why when I remove it am I getting an empty array in my Tasks object?</p>