• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    ASP.NET如何定时调用WebService服务

    下面是一个实际案例:

    某个项目有一个需求,需要定时去调用别家公司的一个Web 系统的 WebService,把他们系统中的数据导入到我们的系统中。由于是调用 Web 接口,这就无法使用数据库中的任务计划实现了。后来想到使用Time 组件,利用Global 中的Application。

    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 sender, EventArgs e) 
      { 
       System.Timers.Timer timer1 = new System.Timers.Timer(); 
       timer1.Interval = 30000; // 30000 毫秒 = 30秒 
       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_BeginRequest(object sender, EventArgs e) 
      { 
      
      } 
      
      protected void Application_AuthenticateRequest(object sender, EventArgs e) 
      { 
      
      } 
      
      protected void Application_Error(object sender, EventArgs e) 
      { 
      
      } 
      
      protected void Session_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(); 
      } 
     } 
    }

    备注:不会受多个用户使用系统的影响,但必须最少有一个用户在使用系统,否则定时器程序不会执行。

    以上内容介绍了ASP.NET如何定时调用WebService服务的方法,希望对大家的学习有所帮助。

    您可能感兴趣的文章:
    • Jquery + Ajax调用webService实例代码(asp.net)
    • asp.net下使用jquery 的ajax+WebService+json 实现无刷新取后台值的实现代码
    • PHP中调用ASP.NET的WebService的代码
    • jQuery Ajax方法调用 Asp.Net WebService 的详细实例代码
    • ASP.NET WebService中使用ASP.NET_SessionId的问题说明
    • 使用ASP.NET一般处理程序或WebService返回JSON的实现代码
    • asp.net(c#)动态修改webservice的地址和端口(动态修改配置文件)
    • asp.net类库中添加WebService引用出现问题解决方法
    • asp.net webservice返回json的方法
    • ASP.NET实现基于Forms认证的WebService应用实例
    • ASP.NET调用WebService服务的方法详解
    • ASP.NET中Webservice安全 实现访问权限控制
    • ASP.NET中基于soaphead的webservice安全机制
    上一篇:ASP.NET中HTML页面的访问验证设置方法
    下一篇:GridView控件如何显示序号
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    ASP.NET如何定时调用WebService服务 ASP.NET,如何,定时,调用,WebService,