Here is the webservice:
Custom classes:
public class A
{
public A()
{
}
public B prop { get; set; }
}
public class B
{
public B()
{
}
public A prop { get; set; }
}
Webmethod:
[WebMethod]
[XmlInclude(typeof(A))]
public object Test()
{
A a = new A();
a.prop = new B();
return a;
}
Here is the client side:
Service ws = new Service();
var response = ws.Test();
So, why is the webservice returning XmlNode list instead of class A? How to solve it?
PS: if I comment public A prop { get; set; } line, it works
[Serializable]attribute is not used by XML Serialization.object, so it's returning the most general possible type. If you didn't meanobject, then don't returnobject.public A prop { get; set; }it will return A as expected. How to achieve this without commenting code line?