First of all keep in mind, that I followed a very much stuff in google about this subject.
I am using WCF
, to exposing 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, as XML, send both Sub
object and Base
object. When I break with debugger in first line of test(Base b)
in b
I can't see sub
field.
The problem is:
<?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 is successfully deserialized, but in object I can see only base
field (equals to 123
), however I can't see field sub
.
Where Am I wrong ?