Can a Web Servive send it's status to a client?

E

Ethan Strauss

Hi,
I have a web service which is doing a lot of processing and taking 4-5
minutes to do so. The processing is split into several discrete steps and I
would like for the service to be able to tell the client when it is done
with each step.
I have tried to do this in a couple of ways and neither have worked. Any
ideas how I might get it to work?

What I have tried was:

1) Splitting out each processing step into a different web method and then
having the client call each method as the one before it finished.
The sort of work, in that the client knew what was happening when,
but the I could not get the service to remember the intermediate results and
thus it did everything after the first step on null objects. I thought of
passing the results back to the client and then having it pass them back to
the service, but there is too much data in the intermediate results for that
to be reasonable.

2) Having the WebService class have a private status string and a public
WebMethod GetStatus which returns that string. The service then updates the
string as appropriate and the client asks for it periodically.
The value of the status string never actually changed. I wrote code
(C#):
status = "Starting Blast analysis.";
BlastSolutionSet thisSolution =
DatabaseAccess.GetExperiment(experimentGuid);
thisSolution.BlastAll();
status = "Collating Blast Data";
thisSolution.AssignBlastResults();
status = "Querying NCBI";
thisSolution.CollectNcbiData();
status = "Done";
In debug mode, the value of status was always "".


Ay thoughts?
Thanks!
Ethan
 
W

WishMaster

The only solution would be to use async web service calls from your client,
probably using threads in your client. The concept is certainly well
documented on google.

Regards

John Timney (MVP)http://www.johntimney.comhttp://www.johntimney.com/blog

"Ethan Strauss" <ethan dot strauss at Promega dot com> wrote in message







- Show quoted text -

Hi Ethan:

As John mentioned the solution is Asynchronous Web Service
implementation. It is bit complecated but once you are familer with
this model/pattern may be you can implement in other areas.

Following are two articals, which can go through you with Asyn WS.
Basic: http://www.braintique.com/research/topic/asynch.shtml
Detailed: http://www.codeproject.com/cs/webservices/wsasync.asp
(including pattern info).

Cheer,
Amer
MCSD.Net
ITIL Certified
 
P

Peter Bromberg [C# MVP]

What I would do in this case - to "keep it simple" is have a GetCurrentStatus
WebMethod that you can poll on a timer from the client. You could either
return a percentcomplete number, or an enum that represents the current state
of the "job". Since ASP.NET WebServices have access to all the ASP.NET
infrastructure, you can use session, Global.asax, etc. for state storage on a
per-session basis. Probably you would not want to try to use ASP.NET Session,
instead a GUID representing the current "job" being a key into a hashtable of
"JobState" objects.
Peter
 
E

Ethan Strauss

Thanks to everyone who responded.
At this point I have more or less given up on this. It would have been nice,
but
it isn't needed. FWIW, I am running an ansynchronous service with another
web method which is GetStatus(). That didn't work :-(
I considered having the service write the status to a database and have the
client poll the database periodically, but decided that was more overhead
than it was worth.
I hope to have more time to look into this because I am sure it will come up
again for me.
Ethan
 
A

Alvin Bruney [MVP]

My personal suggestion.... avoid async service-calls as much as possible.
You need to explain this or at least qualify the statement. Async calls are
there for a reason, when you go against the grain, you need to provide
justification to support your position.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley


z> My personal suggestion.... avoid async service-calls as much as possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top