I am new to WCF and just wondering how to properly get MessageContract inheritance. A simplified version of my setup looks like this: the "base" type of message, and then another "test" message that inherits from it.
[MessageContract]
public abstract class BaseMessage
{ }
[MessageContract]
public class TestMessage : BaseMessage
{ }
Then I have an asynchronous OperationContract in a ServiceContract, which is defined as:
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginFindRequest(BaseMessage request, AsyncCallback callback, object asyncState);
The problem that occurs when calling the BeginFindRequest method and passing the TestMessage instance for the request parameter, WCF deserializes the TestMessage instance for BaseMessage on the service / server side. Since this is defined as an abstract class, this leads to the following error:
"A message cannot be deserialized to the MessageContract BaseMessage type because it does not have a default value (no parameters).
, MessageContract, , .
, : , ? OperationContract ServiceContract - , OperationContracts?