I have have a WCF derived/base contract issue. I have a server interface/contract that returns a BaseThing
object:
[OperationContract]
BaseThing Get_base_thing();
The server that implements this has a DerivedThing
(derived from BaseThing
) and wants to return this as a BaseThing
. How to tell WCF that I only want to transport the BaseThing
part of DerivedThing
?
If in Get_base_thing
I just return a reference to a DerivedThing
then I get a SerializationException
server side.
I think I need to define a DataContractResolver
and I looked at the MSDN article Using a Data Contract Resolver but this is not 100% clear (to me a least).
How should my DataContractResolver
look to tell WCF to only transport the base part of the derived object I pass it?
Is there some way to do this more simply just with KnownType
attribue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…