Method call AFTER service operation wcf returned the result

I have a WCF service operation, and I want the operation call to start with a long-running method, however I want the operation to return its result BEFORE the long method ends.

I tried using the IParameterInspector implementation, but the result of the operation is not returned to the client until the long method finishes.

How can I achieve this, since everything that I start with the operation seems to need to be completed before the result is returned to the client?

Thanks.

+8
wcf
source share
2 answers

If you want to do this on the server, see http://blogs.msdn.com/b/carlosfigueira/archive/2011/05/17/wcf-extensibility-ioperationinvoker.aspx , it shows how to bypass the operation (it is a caching script but it can be adapted to your problem).

If you want to do this on the client, you can simply invoke the operation asynchronously, it will return immediately. And when the long work is completed, you will receive a notification (callback or event) that its results will be ready.

+2
source share

You cannot do this with the standard request / response type binding in WCF, because, as you found out, you will not receive a response until the service finishes processing (or time out). To accomplish what you want, you will need a service where you can run a long-term operation, and then poll the completion status and response results.

NetMsmqBinding supports this script in WCF. All operations for this binding must be a one-way call, since you only put the message in the queue for processing. You will need another endpoint or service configured with a request / response binding for the polling method. A good overview of netMsmqBinding is here.

0
source share

All Articles