Given a (contrived) base class, and a sub class we want to serialize via WCF using the XmlSerializer. We decorate a collection (see the response class) as per the article:
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute.aspx (see remarks section).
Issue is that although the correct WSDL seems to be generated, SVCUtil generates a class file where the GetUserResponse class contains a property named Items. Is this to do with applying [XmlElement] to an array? Although the XmlArray element doesn't have a Type property.
Thanks in advance.
[Serializable]
[XmlType]
public class UserBase
{
public int Id {get;set;}
}
[Serializable]
[XmlType]
public class BasicUser : UserBase
{
public string UserName {get;set;}
}
[Serializable]
[XmlType]
public class SuperUser : UserBase
{
public string UserName {get;set;}
public bool SpecialLevel {get;set;}
}
[Serializable]
[XmlType]
public class GetUserResponse
{
[XmlElement("Users", typeof(User)), XmlElement("SuperUsers", typeof(SuperUser))]
public List<UserBase> Users {get;set;}
}