MessageContract для возврата объекта полиморфа
У меня есть такой сервис
[ServiceContract]
public interface IMyService {
[OperationContractAttribute(Action = "*")]
GenericResponse MyMethod(Message myRequest);
}
[MessageContract]
public class MyResponse : GenericResponse {
// implementation here
}
[MessageContract]
public class GenericResponse{
//implementation here
}
public class MyService: IMyService {
public GenericResponse MyMethod(Message myRequest) {
MyResponse response = new Response();
//implementation here
return response;
}
однако сгенерированный XML не сериализует MyResponse, а вместо этого сериализует объект GenericResponse следующим образом:
<s:Body><GenericResponse/></s:Body>
но мне нужно:
<s:Body><MyResponse/></s:Body>
поскольку это тип, который я возвращаю.
Что я делаю не так?
Я не могу использовать [DataContract] в моей реализации, это может быть MessageContractors или пользовательская сериализация xml.