I am using an interface as input parameter in OperationContract. But when I generate the proxy class at client side, the client method is seen as: GetDat(object value) instead of GetData(IMyObj value)
- Service Interface
[ServiceContract] [ServiceKnownType(typeof(MyObj))] public interface IService { [OperationContract] string GetData(IMyObj value); }
- Service class
public class Service : IService { public string GetData(IMyObj value) { return string.Format("You entered: {0}", value.MyValue); } }
- Interface
public interface IMyObj { int MyValue { get; set; } }
- Data Contract
[DataContract] [KnownType(typeof(IMyObj))] public class MyObj : IMyObj { [DataMember] public int MyValue { get; set; } }
Note: There are a lot of similar questions on stackoverflow regarding to interface parameters and wcf. But they all tell to use the ServiceKnownType attribute and KnownTypeAttribute (Which I did). But it still gives the calling method on the client side an object as parameter type instead of my interface type.