我试图使用WCF服务从基类返回派生类,但我不断收到以下异常
[XmlInclude(typeof(DerivedClass1)), XmlInclude(typeof(DerivedClass2))]
我尝试在WCF服务方法上添加以下所有内容。
1)[SoapRpcMethod]
2)[SoapInclude(typeof(DerivedClass1)), SoapInclude(typeof(DerivedClass2))]
3)public class BaseClass
{
}
public class DerivedClass1:BaseClass
{
}
public class DerivedClass2:BaseClass
{
}
代码:
public BaseClass Validate()
{
if(someCondition)
return new DerivedClass1();
else
return new DerivedClass2();
}
Wcf服务方式:
img