Reputation: 11
I am bit stuck somewhere while designing my solution and therefore need your expertise and suggestions.
The problem is: I have 30 type of requests each having different parameters therefore i am treating these 30 request as 30 different request input but response is same for all request types.
Now I need to create one operation inside my existing wcf service which can cater all 30 types of requests.
I am not getting how to cater this within single operation. I dont want to create the 30 operations to handle the request individually.
Upvotes: 1
Views: 114
Reputation: 31770
If your request types all derive from the same type you can expose them polymorphically using the ServiceKnownTypes attribute:
[DataContract]
[KnownType(typeof(RequestFromThisGuy))]
[KnownType(typeof(RequestFromThisOtherGuy))]
public class UberRequest
{
...
}
[DataContract]
public class RequestFromThisGuy: UberRequest
{
...
}
[DataContract]
public class RequestFromThisOtherGuy: UberRequest
{
...
}
Then your service operation:
[OperationContract]
CommonResponseType DoSomething (UberRequest request)
Upvotes: 2
Reputation: 5691
tricky tricky
public void MyOperation(List<InputType> inputs)
{
// your stuffs here.
}
Upvotes: -1