WCF proxy client generated with wsdl not matching for ServiceContract, XmlSerializerFormat attributes
XmlSerializer uses XmlIncludeAttribute instead of KnownTypeAttribute
to discover child types that are not included in operation contracts. So you might try adding them to the base class:
[XmlInclude(typeof(ChildClass1))]
[XmlInclude(typeof(ChildClass2))]
public class BaseClass {}
The standard WCF DataContractSerializer will serialize everything marked with [DataMember]
- regardless of the .NET visibility (public/protected/private/internal).
When you switch to the XmlSerializerFormat, the behavior changes - now the XmlSerializer will serialize everything that has a public
visibility, and does not have a [XmlIgnore]
marked on it.
I would assume some of your classes and members are not marked with public
and thus don't get serialized anymore. Also the XmlSerializer requires classes to have an explicit, parameter-less constructor which will be used in deserialization - do all your classes have that? And of course, that constructor also needs to be public
.
精彩评论