问题
I am new to .NET and web services. My aim is to create a .asmx webservice in C# which will invoke itself in every 12 hours automatically. So, there won't be anybody invoking its methods but it will invoke itself regularly. I am confused about how to do this with .NET webservices.
回答1:
My suggestion would be to use either a windows service
or a console app
scheduled to run every 12 hours by the host system's scheduling software (Windows Task Scheduler, cron, etc.).
Here is an interesting discussion on the similar requirement like yours to run a method at regular intervals and David has given various options in there.
回答2:
If it's a public webservice (or one available on the Internet, in any case) you can check out the new Azure Scheduler to invoke your webservice on a regular basis.
回答3:
You Can create windows service and setup to call after every 12 hours you can easily find how to create and setup windows service
回答4:
You can Create and schedule Jobs that will invoke every 12 Hours or say at 12am and 12pm everyday using Quartz.NET
You can create your Cron expression using :
http://www.cronmaker.com/
"InitializeScheduler()" calls the job where JobType => typeof(YourClass) with Execute() holding the required method to execute. And cron expression will identify and schedule its time
Please follow the links for further understanding on the implementation :
http://www.quartz-scheduler.net/
http://geekswithblogs.net/TarunArora/archive/2012/11/17/quartz.net-writing-your-first-hello-world-job.aspx
http://simplequartzschedulerincsharp.blogspot.in/
Works best for my requirements
来源:https://stackoverflow.com/questions/24528713/calling-net-webservice-automatically