Differences Between WSDL and XSD
Obviously WSDL and XSD are two entirely different description languages, but I was looking at the outputs of the old wsdl.exe and xsd.exe programs recently to see how they differed. They turned out to generate data type classes that were pretty much the same. Starting with a description that was equivalent to the following data contract, I ran both of the programs.
[DataContract]
public class Data
{
[DataMember]
public int a;
[DataMember]
public string b;
[DataMember]
public List<XmlElement> c;
}
Going through xsd.exe gave me a data type that looked like this (I've deleted some of the surrounding code for clarity):
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.312")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "schemas.datacontract.org/2004/07/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "schemas.datacontract.org/2004/07/", IsNullable = true)]
public partial class Data
{
private int aField;
private bool aFieldSpecified;
private string bField;
private System.Xml.XmlElement[] cField;
public int a
{
get
{
return this.aField;
}
set
{
this.aField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool aSpecified
{
get
{
return this.aFieldSpecified;
}
set
{
this.aFieldSpecified = value;
}
}
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public string b
{
get
{
return this.bField;
}
set
{
this.bField = value;
}
}
[System.Xml.Serialization.XmlArrayAttribute(IsNullable = true)]
[System.Xml.Serialization.XmlArrayItemAttribute(Namespace = "schemas.datacontract.org/2004/07/System.Xml")]
public System.Xml.XmlElement[] c
{
get
{
return this.cField;
}
set
{
this.cField = value;
}
}
}
Going through wsdl.exe gave me a very similar data type except for two differences.
1.
The GeneratedCode attribute is different because it contains the name of the generating program.
2.
When coming from the WSDL version, you don't get the XmlRoot attribute.
The output of the two programs for data types was interchangeable after taking into account these two differences. All of the surrounding code was completely different but I happened to just need the data types and not the proxy classes. This doesn't hold for types that use the SOAP encoding style though. In that case, wsdl.exe uses new behavior that's not present in xsd.exe.
Next time: Network Monitor
Comments
- Anonymous
November 12, 2007
How do I set the user principal name that the client will use when calling the service? The user principal