1

I have the following method signature being exposed via WCF:

public void MethodA(RequestBase request)
{

}

public class RequestA : RequestBase
{

}

There are some concrete classes derived from the RequestBase Class. During the service call using WcfTestClient.exe, how do i pass the actual concrete class (RequestA) to the RequestBase in methodA ?

user384080
  • 4,576
  • 15
  • 64
  • 96

1 Answers1

1

You're looking for the KnownType attribute for your data contracts:

[DataContract]
public class RequestBase
{
}

[DataContract]
[KnownType(typeof(RequestBase))]
public class RequestA : RequestBase
{
}

Then you can pass in a RequestA object where RequestBase is the expected type of the service operation:

var requestA = new RequestA();
serviceClient.MethodA(requestA);
Didaxis
  • 8,486
  • 7
  • 52
  • 89