Link to home
Start Free TrialLog in
Avatar of Kobz46
Kobz46

asked on

Calling dynamic web methods via a windows service

Hi Experts!

We're using a windows service, which runs all the time and has 5 timers defined, that calls specific web methods, via a web service, every second, when it's not locked and available. My question now is:

How can we make the calling of web methods dynamic? In other words, we want to use a config file, define the timers' intervals in there, and specify methods to be called for every timer. Then in our windows service code we will have something like this:

Private Sub timer1_Elapsed(.....)
  .
  .
  .
    theWebserviceObject.DynamicMethod1_SpecifiedForTimer1_InConfigFile()
  .
  .
  .

End Sub

Private Sub timer2_Elapsed(.....)
  .
  .
  .
    theWebserviceObject.DynamicMethod1_SpecifiedForTimer2_InConfigFile()
  .
  .
  .
End Sub

ect
.
.
.

Any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of armoghan
armoghan
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kobz46
Kobz46

ASKER

I'm definately gonna give this a try as it looks promising! :-)

Will get back to you asap!
Thanx 4 the quick response armoghan...
Avatar of Kobz46

ASKER

It worked like a charm thank you!

One more question though, won't hold it against you if i don't get an answer to this one, but i'll add another 75 points to this question;

Do you by any chance know which OTHER windows services should be started first, before i can use my windows service to call a web service?

I know I'm using SQL server to write queries (logs) into the db, so "SQL Server (MSSQLSERVER)" (by default) is definately 1 of them. Any others? Web services or www, or IS or something?

Regards,
kobus
Use ServiceController class to get a snapshort of all the services currently running on your machine at any instance
http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicecontroller(VS.80).aspx

something like
Dim services() As ServiceController
services = ServiceController.GetServices("MyMachineName")
Avatar of Kobz46

ASKER

You don't by any chance know which services are used to call a web service from a windows service? There's a LOT of services running on that machine and i don't want to start every1 if i don't have to...
Avatar of Kobz46

ASKER

This is the code that i managed through google @ this stage, but i dunno which services 2 start...
            'Check whether the SQL server service is running:
            Dim SQLServiceController As New System.ServiceProcess.ServiceController("SQL Server (MSSQLSERVER)", CStr(getConfig("EAPoller.ServerName")))
            If SQLServiceController.Status = ServiceControllerStatus.Stopped Then
                SQLServiceController.Start()
            End If
            SQLServiceController.WaitForStatus(ServiceControllerStatus.Running)
            SQLServiceController = Nothing

Open in new window

I dont know..

May be you should look for WWW service or IIS admin service on XP
or look for the process aspnet_wp.exe running

or may be you look for w3wp.exe running on Windows 2003 server
Avatar of Kobz46

ASKER

Thanx for the feedback armoghan!

Didn't get the services but will struggle with that 4 the time being... maybe raise a question in another category or whatever... :-)
That's not a trainsmash...

Thanx for the help with the methods tho'! Works well...

K