Asp. NET How to call WebService service at timed time-practical tips

Source: Internet
Author: User

Here is a real case:

A project has a requirement that needs to be timed to invoke the WebService of a web system in another company to import the data from their systems into our system. Because it is a call to the Web interface, it cannot be implemented using the task schedule in the database. It was later thought to use the time component to take advantage of the application in global.

Using System; 
Using System.Collections; 
Using System.Configuration; 
Using System.Data; 
Using System.Linq; 
Using System.Web; 
Using System.Web.Security; 
Using System.Web.SessionState; 
  
Using System.Xml.Linq; Namespace MyNet {public class Global:System.Web.HttpApplication {protected void Application_Start (object se 
   NDEr, EventArgs e) {System.Timers.Timer timer1 = new System.Timers.Timer (); Timer1. Interval = 30000; 30000 ms = 30 sec timer1. 
   Elapsed + = new System.Timers.ElapsedEventHandler (time1_elapsed); Timer1. 
   Autoreset = true; Timer1. 
   Enabled = true; Timer1. 
  Start (); } protected void Session_Start (object sender, EventArgs e) {} protected void Application_beginreques T (object sender, EventArgs e) {} protected void Application_AuthenticateRequest (object sender, EventArgs E {} protected void Application_Error (object sender, EventArgs e) {} protected void Sessio N_end (obJect sender, EventArgs e) {} protected void Application_End (object sender, EventArgs e) {} void Time1_elapsed (object source, System.Timers.ElapsedEventArgs e) {localhost. MyWebService ws = new localhost. 
   MyWebService (); Ws. 
  Insertmywebservice (); } 
 } 
}

Note: The system will not be affected by multiple users, but the system must be used by at least one user, otherwise the timer program will not execute.

The above content introduced asp.net how to call the WebService service method regularly, hoped to have the help to everybody's study.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.