Is it possible to schedule a web service?

A

antonyliu2002

I have a web service, which needs to run at regular intervals (e.g.,
once every 2 hours) to create some PDF files for users to download.

I can certainly create a web application which lets user click a
button and generates the PDF file.

But since the PDF files are gonna be the same for all users, so, it
does not make sense to waste the server resources.

Is it possible to schedule a web service to run at regular
intervals?

I do not want to use the Windows Task Scheduler, part of the reason is
that we do not have full access to our clients' Windows system, and
it's cumbersome to get them involved in setting up the task
scheduler. So, I would like to do this completely within the IIS
context.

I googled a little, but could not find anything helpful.

Any idea? Thanks.
 
C

Cowboy \(Gregory A. Beamer\)

You either have to use a scheduler or set up a service on the box that runs
on a timer. You might be able to kludge this with an HTTP Handler, but I am
not sure I would head down that path.

One thing to consider, as a poor man's method, is to have a "time" set into
application that increments by two hours each time it is hit. Then,
automatically update the files when a user hits the site and the "time" has
timed out.

Or, you could make teh PDF request through a page and refresh based on a
"timer" value. This way, you are only updating when people are requesting
the file, but you are updating all PDFs from a single page or HTTP Handler.
 
G

Guest

Anthony,

Web Service similar to a Web Application does not run by itself -
somebody/something has to trigger it. In your particular case, you may not
necessarily want to run the service as a separate process - you can check on
every (user) call whether the required file is already created and stored (in
the file system or ASP cache) and then either create one or retrieve it from
the storage.
 
A

antonyliu2002

Anthony,

Web Service similar to a Web Application does not run by itself -
somebody/something has to trigger it. In your particular case, you may not
necessarily want to run the service as a separate process - you can check on
every (user) call whether the required file is already created and stored (in
the file system or ASP cache) and then either create one or retrieve it from
the storage.











- Show quoted text -

Thanks. I think I probably check the file modification time with the
current time. If their difference is > 2, then create a new PDF,
otherwise, don't create a new one let the user download the existing
PDF.

Of course, there may be a reader/writer race condition if more than
one users wants to download the PDF at the same time. But, we may be
able to synchronize using lock, right?

Sorta enlightenment from what you said.
 
A

antonyliu2002

You either have to use a scheduler or set up a service on the box that runs
on a timer. You might be able to kludge this with an HTTP Handler, but I am
not sure I would head down that path.

One thing to consider, as a poor man's method, is to have a "time" set into
application that increments by two hours each time it is hit. Then,
automatically update the files when a user hits the site and the "time" has
timed out.

Or, you could make teh PDF request through a page and refresh based on a
"timer" value. This way, you are only updating when people are requesting
the file, but you are updating all PDFs from a single page or HTTP Handler.

Thank you very much. But I am not sure how the timeout strategy works.
 
J

John Timney \(MVP\)

There are right ways and wrong ways to do things. My suggestion is the
right way - make your client see that and do the work for them if you have
to.

You could probably use SQL server and use that to call a webservice on a
timer job (if your using it).

You could even likely invoke a thread in application on start event that
acts as a poll and spawns your webservice.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top