Saint
Saint

Reputation: 5469

Is it possible to use an interface type as parameter type in a WCF operation?

There's some interface:

public interface IMessage
{
    string Content;
    Person Sender;
}

public class Priv : IMessage
{
    public string Content { get; set; }
    public Person Sender { get; set; }
    private int whatever;
}

public class Publ : IMessage
{
    public string Content { get; set; }
    public Person Sender { get; set; }
    private DateTime something;
}

Is it possible to use in wcf service IMessage instance? Like void SomeMethod(IMessage toSend)?

Upvotes: 2

Views: 103

Answers (1)

Jan
Jan

Reputation: 16042

Yes, that is possible. You have to tell the Service the list of expected implementations you will send by using the KnownTypes attribute

Upvotes: 3

Related Questions