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

Discussion in 'ASP .Net Web Services' started by Ethan Strauss, Jan 29, 2007.

  1. 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
     
    Ethan Strauss, Jan 29, 2007
    #1
    1. Advertising

  2. Ethan Strauss

    Scott M. Guest

    No.


    "Ethan Strauss" <ethan dot strauss at Promega dot com> wrote in message
    news:uWMHOL$...
    > 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
    >
    >
    >
     
    Scott M., Jan 29, 2007
    #2
    1. Advertising

  3. 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.com
    http://www.johntimney.com/blog


    "Ethan Strauss" <ethan dot strauss at Promega dot com> wrote in message
    news:uWMHOL$...
    > 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
    >
    >
    >
     
    John Timney \(MVP\), Jan 30, 2007
    #3
  4. Ethan Strauss

    WishMaster Guest

    On Jan 30, 9:17 pm, "John Timney \(MVP\)"
    <> wrote:
    > 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 messagenews:uWMHOL$...
    >
    >
    >
    > > 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- Hide quoted text -

    >
    > - 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
     
    WishMaster, Jan 30, 2007
    #4
  5. 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

    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "Ethan Strauss" wrote:

    > 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
    >
    >
    >
    >
     
    Peter Bromberg [C# MVP], Jan 30, 2007
    #5
  6. 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

    "Ethan Strauss" <ethan dot strauss at Promega dot com> wrote in message
    news:uWMHOL$...
    > 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
    >
    >
    >
     
    Ethan Strauss, Feb 1, 2007
    #6
  7. > 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


    "MasterGaurav (www.edujini-labs.com)" <>
    wrote in message news:Oin$...
    >> it isn't needed. FWIW, I am running an ansynchronous service with another
    >> web method which is GetStatus(). That didn't work :-(

    >

    z> My personal suggestion.... avoid async service-calls as much as possible.
    >
    > They are more pain practically than theoretically.
    >
    >> 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.

    >
    > Well, instead of putting in database, you may want to cache it.
    >
    > A simple solution may be something like this:
    >
    > 1. StartService (web service to start) returns a simple string - may be a
    > GUID
    > 2. QueryStatus takes this GUID as a parameter and returns a simple %age on
    > completion.
    >
    > Now, the %age completion doesn't need to be in database. You may very well
    > put it in server-cache whose key is this GUID.
    >
    > That should do.
    >
    > Keep in mind that it would fail in the case of web-farm deployment since
    > the cache would not be in session-server but on the same machine as in
    > ASP.Net... I hope I am wrong.
    >
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish | www.mastergaurav.com
    > www.edujini-labs.com
    > http://eduzine.edujini-labs.com
    > -----------------------------------------
    >
    >
     
    Alvin Bruney [MVP], Feb 11, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. saha
    Replies:
    0
    Views:
    4,069
  2. Shug
    Replies:
    13
    Views:
    902
    Philipp
    Dec 15, 2006
  3. harryos
    Replies:
    0
    Views:
    388
    harryos
    Oct 13, 2010
  4. Tony V
    Replies:
    0
    Views:
    174
    Tony V
    Aug 12, 2003
  5. nirk

    Web servive asynchronous call fails

    nirk, Jan 23, 2004, in forum: ASP .Net Web Services
    Replies:
    4
    Views:
    195
    Sami Vaaraniemi
    Jan 23, 2004
Loading...

Share This Page