views:

41

answers:

3

Hi all,

I'm new to web development so I'm not sure what's the best option for the problem that I'm having.

Basically I have a web application that calls a web service for processing some data. This process may take a long time (hours) and I would to know if there is an easy way to send some status information to the client from time to time.

Right now, the client makes the request from the browser and it just waits there until it finishes.

How can I send some information from the web service? I would like to send a percentage and some additional text specifying what is being done.

Thanks

A: 

Maybe you can poll another method for status?

Marko
How can I do that? The execution on the client is stopped waiting for the web service to finish.
You can spawn a new thread for polling just before call, and kill it after you get result...
Marko
Or maybe timer would be more elegant/easy to implement...
Marko
A: 

WCF services can be marked as [OneWay] so that they don't return a response. or, you could have the service kick off the process in an async manner and then just return to the client that the process has/or hasn't kicked off.

Then, the client can poll another method as the other user has suggested.

If you process takes hours you definitely can't use a sync service because you'll hit your execution timeout or rather the connection timeout for the client.

Famous Nerd
Thanks for the information. I didn't know about the [OneWay] option.
The gotcha about OneWay is that even if your service errors you won't know so it makes the polling subsequent step all the more important. I'd say that if you're comfortable with dispatching a "job" or async processing from within the syncronous service then you'll get both: feedback from the service during the initial kickoff and as well the ability to run a long running process in the wcf service.You can see here that Steve Gilham notes that even a duplex service may do the trick: http://stackoverflow.com/questions/1142698/dealing-with-a-longer-running-process-in-wcf
Famous Nerd
Thanks again. I really appreciate your help.
A: 

If I were you, I would make the original request asynchronous, as in instead of waiting for the response, it just "starts" the task and returns immediately. Then I would have a separate method on your web service that the app can poll periodically to get the status of the job. once it completes, it can display the data like the original request was doing.

if you want to do it synchronously, you can turn off Response.Buffer and write directly to the response.

dave thieben
Thanks, I will try it that way.