Solved

Calling dynamic web methods via a windows service

Posted on 2007-11-18
8
269 Views
Last Modified: 2010-08-05
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?
0
Comment
Question by:Kobz46
  • 5
  • 3
8 Comments
 
LVL 18

Accepted Solution

by:
armoghan earned 125 total points
ID: 20311645
Use Reflection

Something like
theWebserviceObject.GetType.InvokeMember("DynamicMethod1_SpecifiedForTimer1_InConfigFile", Reflection.BindingFlags.Default Or Reflection.BindingFlags.InvokeMethod, Nothing, theWebserviceObject, Param)
0
 

Author Comment

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

Will get back to you asap!
Thanx 4 the quick response armoghan...
0
 

Author Comment

by:Kobz46
ID: 20394369
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
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 18

Expert Comment

by:armoghan
ID: 20394413
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")
0
 

Author Comment

by:Kobz46
ID: 20394650
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...
0
 

Author Comment

by:Kobz46
ID: 20394661
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

0
 
LVL 18

Expert Comment

by:armoghan
ID: 20394731
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
0
 

Author Comment

by:Kobz46
ID: 20440285
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
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question