First of all, keep in mind that I followed this question on Google. I use WCF to expose some services. I have something like:
[DataContract] [KnownType(typeof(Sub))] public class Base { [DataMember] public int base; } [DataContract] public class Sub : Base { [DataMember] public int sub; } [ServiceContract] [ServiceKnownType(typeof(Sub))] public interface IServices { [OperationContract] public void test(Base b); }
I would like to be able, like XML, to send Sub and Base objects. When I break with the debugger in the first line of test(Base b) in b , I do not see the Sub field.
The problem is this:
<?xml version="1.0"?> <soapenv:Envelope xmlns:xs="http://www.w3.org/2003/05/soap-envelope/" soapenv:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> <soapenv:Header/> <soapenv:Body> <xs:test> <xs:b> <xs:base>123</xs:base> <xs:sub>1234</xs:sub> </xs:b> </xs:test> </soapenv:Body> </soapenv:Envelope>
This XML was successfully deserialized, but in the object I see only the Base field (equal to 123 ), however I do not see the Sub field.
Where am I mistaken?
user7361363
source share