When I use svcutil.exe to generate a Customer class from the definition contained in the xsd file:
<xs:schema ...>
<xs:element name="customer" type="Customer" nillable="true" />
<xs:complexType name="Customer">
<xs:sequence>
<xs:element name="id" type="xs:decimal" minOccurs="0" />
<xs:element name="first_name" type="xs:string" />
<xs:element name="last_name" type="xs:string" />
<xs:element name="phone" type="Phone" minOccurs="0" />
<xs:element name="email" type="Email" minOccurs="0" />
<xs:element name="personal_id" type="xs:string" minOccurs="0" />
<xs:element name="address" type="Address" minOccurs="0" />
<xs:element name="status" type="CustomerStatus" />
</xs:sequence>
</xs:complexType>
</xs:schema>
I get the following definition of the class:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Customer", Namespace="http://www.bluewhite.pl/api/1.0")]
public partial class Customer : object, System.Runtime.Serialization.IExtensibleDataObject
{
With the Name property of DataContractAttribute having an invalid value: "Customer" (starting with uppercase letter), since, according to name property of the xs:element, it should be: "customer" (starting with lowercase letter).
I start svcutil.exe as follows:
svcutil.exe" *.xsd /t:code /dconly /n:*,Esap.AdtZapisoMessages /o:Messages.cs /tcv:Version35
The generated xml must contain a root element named "customer", and I ask you, why svcutil.exe makes this error.