Solved

Calling dynamic web methods via a windows service

Posted on 2007-11-18
8
267 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now