I have been googling and prototyping with no success this idea and wanted to check that it is possible. I have WCF server client set up.
I have a object with datacontracts and datamembers. I am doing the desalinization on the client. The method is also on the client.
[Serializable]
[DataContract (Namespace = "www.doesnotmatter.com")]
[XmlRoot("home")]
public partial class BaseModel
{
[DataMember(IsRequired = false)]
public string prop1
{ get; set; }
[DataMember(IsRequired = false)]
public string prop2
{ get; set; }
[DataMember(IsRequired=false)]
public string prop3
{ get; set; }
}
I am trying to deserialize from xml to an object the method below is my function
public T FromXmlString<T>()
{
var reader = new StringReader(xmlConfiguration);
var serializer = new XmlSerializer(typeof(T), "www.doesnotmatter.com");
var instance = (T)serializer.Deserialize(reader);
reader.Dispose();
return instance;
}
The xml is
<home>
<prop1>aaaaa</prop1>
<prop2>bbbbb</prop2>
<prop3>cccccc</prop3>
</home>
I keep getting the error
InnerException = {"<Task xmlns=''> was not expected."}
So I am taking the XML above and want to deserialize into the BaseModel above. EDIT:
The base Model object is sitting on the server, I am on the client and have XML I want to deserialize into that given object (BaseModel). I think it is a namespace problem where it cannot deserialize from the xml into the object correctly but am not sure.
I am really unsure what the problem is, can anyone see it?