I have a WCF service with method:
[OperationContract]
public bool TestCustomRequest(RequestBase request)
{
return true;
}
In referenced Class Library project I have 2 classes:
[DataContract]
public abstract class RequestBase
{
[DataMember]
public string Id { get; set; }
[DataMember]
public RequestTypeEnum RequestType { get; set; }
}
And inherited class:
[DataContract]
public class CustomRequest : RequestBase
{
[DataMember]
public string CompanyId { get; set; }
}
When on client side I'm adding service reference, I can see only RequestBase
class. Is it possible, to add all classes that inherits RequestBase
into service reference and initialize them on client side?
Or I have to overload TestCustomRequest
method for each possible incoming parameter type ?
Thank you
You could try:
[DataContract]
[KnownType(typeof(CustomRequest))]
public abstract class RequestBase
{
[DataMember]
public string Id { get; set; }
[DataMember]
public RequestTypeEnum RequestType { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.