Trapping a client timeout in a webservice method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MrXLand
    New Member
    • Jun 2013
    • 1

    Trapping a client timeout in a webservice method

    I am trying to find out how to trap a client timeout within a webservice method call.

    I have a particular webservice method which does several things. The first thing it does it create a unique reference and what I want to be able to do is return it to the client if the method timesout because it is stuck in a subsequent part of the call. A try {} catch {} on the server doesn't seem to be invoked when the client call times out. Is there some other way of trapping that or do I have to go down the route of separating the server parts into separate webmethods?

    e.g. In summary:

    Code:
    CLIENT CODE
    try {
      string response = ServerCall();
    } catch (Exception e) {
      // This is part is invoked when the time out occurs
    }
    
    ---
    SERVER CODE
    [WebMethod]
    public string ServerCall() {
      string myID = String.Empty;
    
      try {
        myID = Part1GenerateUniqueID();
         System.Threading.Thread.Sleep(600000);
         Part2DoMoreStuff();
         return myID; 
      } catch (Exception e) {
        // This is never called when the webmethod times out
          return myID;
      }
    Last edited by Rabbit; Jun 13 '13, 03:43 PM. Reason: Please use code tags when posting code.
Working...