I’m trying to write a WCF Service to populate a grid using a DataContract.
When I try to import the XML into an XSD then into a DataContract I cannot get the xml to conform to the XML defined for the grid.
I’m expecting the following:
<?xml version="1.0" encoding="utf-8"?>
<rows xsi:noNamespaceSchemaLocation="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row id="45C019B5-86A7-4DF9-9AA1-16CC4529EA1A">
<userdata name="workflow_type">PRINT_ONDEMAND</userdata>
<cell>Quick Strike</cell>
<cell>Inactive</cell>
<cell>Data Data Data</cell>
</row>
<row id="50799F82-C3A3-4600-A4EA-9501E1408B8D">
<userdata name="workflow_type">EMAIL_GROUPED</userdata>
<cell>e-Strike</cell><cell>Inactive</cell>
<cell>Data Data Data</cell>
</row>
</rows>
But I’m getting this:
<rows xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<row>
<row z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<cell>
<cell z:Id="i2"><Value>Strike</Value></cell>
<cell z:Id="i3"><Value>Inactive</Value>
</cell><cell z:Id="i4"><Value> Data Data Data</Value></cell>
</cell>
<id>45c019b5-86a7-4df9-9aa1-16cc4529ea1a</id>
<userdata>
<userdata z:Id="i5"><Value>Print</Value><name>workflow_type</name></userdata>
</userdata>
</row>
<row z:Id="i6" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<cell>
<cell z:Id="i7">
<Value>e-Strike</Value></cell>
<cell z:Id="i8"><Value>Inactive</Value></cell>
<cell z:Id="i9"><Value> Data Data Data</Value></cell>
</cell><id>50799f82-c3a3-4600-a4ea-9501e1408b8d</id>
<userdata><userdata z:Id="i10"><Value>Email</Value>
<name>workflow_type</name></userdata>
</userdata>
</row>
</row>
</rows>
my Data Contract is defined as this
[code]
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Xml.Schema;
using System.Xml.Serialization;
///
[GeneratedCode(“xsd”, “4.0.30319.1”)]
[Serializable]
[DebuggerStepThrough]
[DesignerCategory(“code”)]
[XmlType(AnonymousType = true)]
[XmlRoot(Namespace = “”, IsNullable = false)]
[DataContract(Name = “rows”, Namespace = “”)]
[KnownType(typeof(rowsRowCell))]
[KnownType(typeof(rowsRow))]
[XmlSerializerFormat]
public class rows
{
///
[XmlElement(“row”, Namespace = “”), DataMember(Name = “row”)]
public rowsRow[] Items { get; set; }
}
///
[GeneratedCode(“xsd”, “4.0.30319.1”)]
[Serializable]
[DebuggerStepThrough]a
[DesignerCategory(“code”)]
[XmlType(AnonymousType = true)]
[DataContract(Name = “row”, Namespace = “”,IsReference = true)]
public class rowsRow
{
///
[XmlElement(“userdata”, Form = XmlSchemaForm.Unqualified, IsNullable = true), DataMember(Name = “userdata”)]
public rowsRowUserdata[] userdata { get; set; }
/// <remarks />
[XmlElement("cell", Form = XmlSchemaForm.Unqualified, IsNullable = true), DataMember(Name = "cell")]
public rowsRowCell[] cell { get; set; }
/// <remarks />
[XmlAttribute, DataMember]
public string id { get; set; }
}
///
[GeneratedCode(“xsd”, “4.0.30319.1”)]
[Serializable]
[DebuggerStepThrough]
[DesignerCategory(“code”)]
[XmlType(AnonymousType = true)]
[DataContract(Name = “userdata”, Namespace = “”, IsReference = true)]
public class rowsRowUserdata
{
///
[XmlAttribute, DataMember(Name = “name”)]
public string name { get; set; }
/// <remarks />
[XmlText, DataMember]
public string Value { get; set; }
}
///
[GeneratedCode(“xsd”, “4.0.30319.1”)]
[Serializable]
[DebuggerStepThrough]
[DesignerCategory(“code”)]
[XmlType(AnonymousType = true)]
[DataContract(Name = “cell”, Namespace = “”, IsReference = true)]
public class rowsRowCell
{
///
[XmlText, DataMember]
public string Value { get; set; }
}[/code]
How should I be writing my DataContract? Is there an existing data contract that I can re-use?
Thanks,
Brian