Solved

Calling dynamic web methods via a windows service

Posted on 2007-11-18
8
270 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
How our DevOps Teams Maximize Uptime

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

 
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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

820 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