这是网络服务:
自定义类:
public class A
{
public A()
{
}
public B prop { get; set; }
}
public class B
{
public B()
{
}
public A prop { get; set; }
}
网络方法:
[WebMethod]
[XmlInclude(typeof(A))]
public object Test()
{
A a = new A();
a.prop = new B();
return a;
}
这是客户端:
Service ws = new Service();
var response = ws.Test();
那么,为什么 web 服务返回 XmlNode 列表而不是 A 类?如何解决?
PS:如果我评论public A prop { get; set; }
行,它可以工作