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.
The relevant portion of the xsd to this question is here:
<xs:element name="Tasks">
<xs:complexType>
<xs:sequence>
<xs:element ref="Task" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Task"> ... </xs:element>
The xsd created this:
/// <remarks/>
[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 {
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Task")]
public Task[] Task;
}
/// <remarks/>
[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 { ... }
SOAPUI created a soap request from the WSDL that looks like this:
<Tasks>
<Task>
<Task>
.. task data here
</Task>
</Task>
</Tasks>
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'
After finding the extraneous node in the generated SOAP request, I made my new request look as such:
<Tasks>
<Task>
...task data here
</Task>
</Task>
Now the deserializer 'works', but in my method the Tasks object contains an empty Task array.
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?