How to specify WCF operation to call at run time?

205 Views Asked by At

I have a WCF WF web service (workflow service 4.0) and each operation of this service has the same signature, but different name.

My system receives an event {int eventType, int entityId} and needs to dispatch that event to an operation on the web service I mentioned above using configuration.

E.g. suppose I have config file (which maps eventType to an operation name):

1 -> "StartOrder"
5 -> "StopOrder"
8 -> "ProcessPaymet"
9 -> "RepartFraud"

so if I receive eventType equal to 5 I need to do something like:

string operationName = eventTypeToOperationMap[eventType];
new ChannelFactory<IMyWebService>().CreateChannel().CallOperation(operationName, entityId);

and IMyWebService has a method:

void StopOrder(int entityId);

Background: IMyWebService is a windows workflow foundation 4.0 workflow service. I want to be able to add new entry point to the web service, and changing config file for event dispatcher, without having to recompile event dispatcher.

1

There are 1 best solutions below

0
On

You will most likely need to call another service (or another operation on your service) which takes the eventType as a parameter. Inside that operation, you will create a new channel and call the corresponding operation (just like you're already doing).