views:

223

answers:

2

I can abort the web service call from client by calling ABORT method of web service proxy.

However at server where web service is hosted, the call only ends when it completes the processing. As server doesn’t expect any other inputs related to already called web method while processing it, I am not able to close it from client.

Is there any way I can also abort the call at server i.e. stop the large calculation (and pulling some data from database server also) which server is working on?

+1  A: 

There's certainly no way to do this if you are using ASMX web services. Perhaps someone else can speak to whether it's possible with WCF.

In general, it will require you to write your service to expect interruption. Most service code is not written that way.

Are you expecting to abort requests frequently? If not, then it may be best to simply do nothing on the server.

John Saunders
I am not expecting it to abort very frequently however the calculation is very large; so if user decides to do something else i.e. somehow want to ignore the result then I think so it is better to stop that server process.
Sun
A: 

Since you're talking about a simple synchronous request-response, I don't know how you would do it.

How long does a method call usually take?

The behaviour you want really sounds like:

  • Start a sequence of actions that does something (processes some data), get back a cookie
  • When process is complete (poll/get notified), fetch result using cookie
  • Pass control instructions, like abort, using the cookie

This really sounds like modelling your processing as a workflow, and not a function call.

If you find that there is great benefit to switching to this model of doing things, then yes, you have options. Otherwise it may well be simpler to just eat the cost of (infrequently) wasted calculations.

Nader Shirazie