I'm trying to serialize below class using the SoapCore and DataContractSerializer the way the property that holds object (TestProperty) is omitted in the soap message and the element name defines its type name (SomeType in this example)
[DataContract]
[KnownType(typeof(SomeType))]
[KnownType(typeof(SomeType1))]
[KnownType(typeof(SomeType2))]
public class TestClass {
public string Prop1 {get;set;}
public string Prop2 {get;set;}
[DataMember]
public object TestProperty { get;set; }
}
The desired output would look like this:
<TestClass xmlns="...">
<Prop1>test</Prop1>
<Prop2>test</Prop2>
<SomeType></SomeType>
</TestClass>
..instead of what the DataContractSerializer produces now:
<TestClass xmlns="...">
<Prop1>test</Prop1>
<Prop2>test</Prop2>
<TestProperty i:type="SomeType">...</TestProperty>
</TestClass>
Is there a way to achieve this? I need this in order to keep compatibility with a system written in c++, which expects the element and its type to be declared as a element having type as name instead of using i:type attribute.