Serializing works but deserializing is missing data.

I am exposing a POST method in a wcf service for a given set of nested classes. Everything works fine, even serializing, except when I post the *same* xml I create through serializing an instance, the Umber.Amethysts property is empty.
[XmlRoot("MyRoot", Namespace = "myNamespace")]
public class MyRoot
private Indigo indigo;
public MyRoot()
this.indigo = new Indigo();
[XmlElement("Indigo")]
public Indigo Indigo
get
return this.indigo;
set
this.indigo = value;
public class Indigo
private Maroon maroon;
private Umber umber;
public Indigo()
this.maroon = new Maroon();
this.umber = new Umber();
[XmlElement("Maroon")]
public Maroon Maroon
get
return this.maroon;
set
this.maroon = value;
[XmlElement("Umber")]
public Umber Umber
get
return this.umber;
set
this.umber = value;
public class Umber
private List<Amethyst> amethysts;
public Umber()
this.amethysts = new List<Amethyst>();
[XmlElement("Amethysts", Namespace = "")]
public List<Amethyst> Amethysts
get
return this.amethysts;
set
this.amethysts = value;
public class Amethyst
private string name;
private string value;
[XmlElement("Name")]
public string Name
get
return this.name;
set
this.name = value;
[XmlElement("Value")]
public string Value
get
return this.value;
set
this.value = value;
If I manually create the instance:
MyRoot data = new MyRoot
Indigo = new Indigo
Maroon = new Maroon
SomeField = "text..."
Umber = new Umber
Amethysts = new List<Amethyst>
new Amethyst { Name = "foo", Value = "bar"},
new Amethyst { Name = "baz", Value = "biz"}
It serializes a pair of <Amethyst> tags but posting this very same serialized text representation back leaves the Umber element empty?
Anyone know what I am missing?
Thanks!

Hi Ritmo2k,
I have tested your code in my side, then in oder to get the xml data, I have created the following OperationContract GetDataUsingDataContract() with the RequestFormat=WebMessageFormat.Xml
and ResponseFormat=WebMessageFormat.Xml:
public MyRoot GetDataUsingDataContract()
MyRoot data = new MyRoot
Indigo = new Indigo
Maroon = new Maroon
SomeField = "text..."
Umber = new Umber
Amethysts = new List<Amethyst>
new Amethyst { Name = "foo", Value = "bar"},
new Amethyst { Name = "baz", Value = "biz"}
return data;
After that I can get the following result as following:
So please try to rebuild your project and test it again.
If it still can not help, please try to post a simple reproduce project in here.
Besides, if I have misunderstood you, please feel free to let me know.
Best Regards,
Amy Peng
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

Maybe you are looking for

  • Abap-- urgent

    hi all..         can any one provide me with the links od the site tat provide me with the abap tips on performance tuning in abap,reports, ALV smart forms,IDOC, DDIC objects .. and entire abap.. thnx

  • Error while installing the Microsoft Dynamics CRM 2013 Report Authoring Extension set up

    HI Experts, I am trying to install Report Authoring extension tool to work with MS CRM 2015 online reports but unable to install, getting below error even though I am having VS 2013, SQL Server 2014 and Data tools for VS 2013 installed on my machine.

  • Can't share any documents

    Can someone help with not being able to share any documents?

  • How to use dynamic column fields in formulas

    Hi, we changed from CR 8.5 to CR XI R2. Many of our reports use dynamic queries with different count of columns. These reports are designed for the maximum count of columns. This works fine with CR 8.5 but with CR XI R2 it seems to be that if one of

  • CS5 Photomerge - how to avoid those strange jig-saw lines in the sky

    Here is one image out of 4 that I am merging [just an example of one of many I do] you will note that the sky area to the left of the rainbow is clear and normal. When using Photomerge direct from bridge and on RAW files regardless of resolution I am