Avatar of fmichail
fmichailFlag for Canada

asked on 

can I run a web service on my site (asmx) in a preset time

I want to perform a function like refresh the items list from another site regularly without the user request. How I do that in vb.net (like a timer kind of logic)
Microsoft IIS Web ServerASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
fmichail
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Its for ASP.NET right? You would have to use JavaScript.

Following examples show auto refreshing the page but same technique can be used to refresh a list

http://forums.asp.net/p/1564306/3890239.aspx

http://geekswithblogs.net/willemf/archive/2005/10/30/58563.aspx

You can also use a timer

http://msdn.microsoft.com/en-us/library/system.web.ui.timer.aspx
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

I don't believe that this type of operation is appropriate for a web service.  JavaScript may work well for a web site, but not a web service.  Web Services are better at pull operations on demand.  I would look into some other type, like a Windows Service, or a scheduled task.
Which way round do you want this update to take place?

Scenario 1 : User loads a web page and part of the page requires regular updating with content from the same server (important distinction). Use something like Prototype's http://api.prototypejs.org/ajax/Ajax/PeriodicalUpdater/
Scenario 2 : User loads a web page and part of the page requires regular updating with content from a different server. Use something like Prototype's http://api.prototypejs.org/ajax/Ajax/PeriodicalUpdater/ but with a proxy running on your own server - You need to know about Same Origin Policy.
Scenario 3 : You have a database and you want to update a table with data from another website. Using your language of choice, create a script to pull the data and update the database.

Other scenarios will exist.
Avatar of fmichail
fmichail
Flag of Canada image

ASKER

The scenario that I am targetting is:

On Friday @10:00 PM (server time), an operation in the web service starts automatically (unattended) without any user being on the site. The task will set the site in maintenance mode, and starts silently refreshing the site database from the XML exposed from another site, and after the database is refreshed, the site is set back to Working mode.

I am not interested in the operation itself, it is how to make it start on the server automatically. I would suppose that the server provider will not accept that I install a windows service to call the webservice operation, or to install an executable that I can ask for creating a scheduled job to run regularly. Thanks
Avatar of Gary Davis
Gary Davis
Flag of United States of America image

You need to use the Task Scheduler running on some server set up to call the web service on the schedule you want. One example I use has the task scheduler run a PowerShell script that does the work.It helps if you can call the web service passing the parameters (in any) in the query string (GET vs. POST).

See File.ps1 script attached - schedule via task scheduler.
$url = 'http://www.webserver.com/FormGen.asmx/RunProcess?customerId=123&type=something'

$html = (New-Object net.webclient).DownloadString($url)

#Send-MailMessage -to yourself@gmail.com -Subject "test web service" -from yourself@gmail.com
    -BodyAsHtml $html -SmtpServer smtp.mailserver.com

exit

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gary Davis
Gary Davis
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of fmichail
fmichail
Flag of Canada image

ASKER

gardavis

How to start powershel with windows interface. I want to Set -ExecutionPolicy RemoteSigned but I am getting an error (No parameter is known to be ExecutionPolicy), and when I try your powershell command it does not work because of the restricted ExecutionPolicy
Avatar of fmichail
fmichail
Flag of Canada image

ASKER

Thanks
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo