I have a schema I am trying to compile into data contracts. I have found if an element is defined as <xs:element name="DogRequest" type="Dog"></xs:element>
no class is generated for DogRequest. I would like to use svcutil as I have multiple namespaces to generate, and xsd.exe only allows one. Plus I have a few elements using the same type, and xsd.exe only generates one of them. Does anyone know if there is a way to generate classes for this schema?
I'm using a generic web service that takes an XML payload. I am hoping use WCF to still build the message.
Schema
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:complexType name="Dog">
<xs:sequence>
<xs:element name="Name" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="DogRequest" type="Dog"></xs:element>
</xs:schema>
Compiled with svcutil /dconly XMLSchema1.xsd
This will generate 1 class for Dog, but nothing for DogRequest.
xsd.exe will generate 1 class for Dog with DogRequest
svcutil output
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Dog", Namespace="http://tempuri.org/XMLSchema1.xsd")]
public partial class Dog : object, System.Runtime.Serialization.IExtensibleDataObject
{
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
private string NameField;
public System.Runtime.Serialization.ExtensionDataObject ExtensionData
{
get
{
return this.extensionDataField;
}
set
{
this.extensionDataField = value;
}
}
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, EmitDefaultValue=false)]
public string Name
{
get
{
return this.NameField;
}
set
{
this.NameField = value;
}
}
}
XSD Output
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd")]
[System.Xml.Serialization.XmlRootAttribute("DogRequest", Namespace="http://tempuri.org/XMLSchema1.xsd", IsNullable=false)]
public partial class Dog {
private string nameField;
/// <remarks/>
public string Name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
}