Asynchronous WebServices

Last post 11-06-2009 3:50 PM by Bose Thirumalai. 5 replies.

Sort Posts:

  • Asynchronous WebServices

    11-04-2009, 4:43 PM

    Hi,

       I need to call a WebService for every 5 min which will  create a Log file based on the transactions of Inserts and Updates in the Database.

     IS there a way to call the Web Service for every specified time interval?

     I can understand this process is going to happen Asynchronously because the result should be returned for the Log file after every 5  min.

    I know that we can achieve this with Timer control and updatepanel but i dont want to use any timercontrol or updatepanel in my page.

    Please let me know How can i call Web service Asynchronously for specified time interval.

    Regards,

    Bose Thirumalai

     

      

  • Re: Asynchronous WebServices

    11-04-2009, 4:51 PM
    • All-Star
      123,969 point All-Star
    • XIII
    • Member since 06-30-2002, 11:59 PM
    • Essen, Belgium
    • Posts 13,703
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Hi,

    Create a windows service that performs this task.

    Grz, KRis. 

  • Re: Asynchronous WebServices

    11-04-2009, 4:55 PM
    Answer
    • Contributor
      3,384 point Contributor
    • Danish Ali
    • Member since 08-08-2008, 11:22 PM
    • Fort Lauderdale, US
    • Posts 468

    You can create a window service. If you don't want to create a window service, you can use JQuery to achieve it.

    Following script is an example for it. It sends the request to webservice  after every 1 sec.

    <script src="jquery.js"></script>
    <script>
    $
    (document).ready(function()
    {
       
    //ajaxTime.asmx is called every second to get time from server
       
    var refreshId = setInterval(function()
       
    {
         $
    ('#timeval').load('ajaxTime.asmx?randval='+ Math.random());
       
    }, 1000);

       
    //stop the clock when this button is clicked
       $
    ("#stop").click(function()
       
    {
         clearInterval
    (refreshId);
       
    });
    });
    </script>
    If my post solves your problem, please mark it as an answer.
  • Re: Asynchronous WebServices

    11-04-2009, 5:17 PM
    • Member
      127 point Member
    • rilov
    • Member since 07-10-2007, 2:28 PM
    • WEST HAVEN
    • Posts 33

    var seconds=10;
    var minutes=10
    function YourTimer() 
    {
      seconds--;
       if (seconds<1) 
       {
     
      minutes--;  
       seconds=10;
           //Call your webservice
          }
          
    else
    {
    setTimeout("YourTimer()", 1000);
    }
      
    }
    var seconds=10;
    var minutes=10
    function YourTimer() 
    {
      seconds--;
       if (seconds<1) 
       {
     
      minutes--;  
       seconds=10;

           //Call your webservice
          }
          
    else
    {
    setTimeout("YourTimer()", 1000);
    }
      
    }
    this will function as a javascript timer

    I have not failed. I've just found 10,000 ways
    that won't work
    -Thomas Edison
  • Re: Asynchronous WebServices

    11-05-2009, 11:07 AM
    • Contributor
      6,026 point Contributor
    • atconway
    • Member since 09-24-2007, 9:20 PM
    • Florida U.S.A
    • Posts 1,250

    Here is what you need to complete your solution; you can accomplish this entire task much easier using a Windows Service as recommended prior.  However, I do not recommend that you use any type of Timer regardless the type (System.Timers.Timer, System.Threading.Timer, etc,) to execute the process on an interval due to thread issues that could arise.

    I have implemented a Windows Service within the last few months that does exactly what you are doing; run a periodic process on a set time interval.  A better method IMO is to use a 'RegisterWaitForSingleObject' method from the System.Threading namespace.

    As defined in the MSDN:  "Registers a delegate to wait for a WaitHandle, specifying a 32-bit signed integer for the time-out in milliseconds."

    This method is well laid out in the following Blog entry by Mebyon Kernow:

    http://blogs.msdn.com/morgan/archive/2008/12/18/periodic-execution-in-net.aspx

    Here is the MSDN Documentation:

    http://msdn.microsoft.com/en-us/library/w9f75h7a.aspx

    ...and lastly, you might be saying "I don't know how to create and use a Windows Service in .NET!".  Well to get you going on that (there are quite easy by the way to get up and running), check out the following site:

    Walkthrough: Creating a Windows Service Application in the Component Designer:

    http://msdn.microsoft.com/en-us/library/zt39148a.aspx

    That should be everything you need, hope this helps! Smile

    Thank you,   >[Blog]<

    "The best thing about a boolean is even if you are wrong, you are only off by a bit." :D
    -anonymous

  • Re: Asynchronous WebServices

    11-06-2009, 3:50 PM

    Hi Danish

     Thanks for your response.

     I think i have got some idea and i need to implement the same in different way.

     Anyway thanks for your reposnse.

    Regards

    Bose Thirumalai

     

     

Page 1 of 1 (6 items)