Solved

Calling dynamic web methods via a windows service

Posted on 2007-11-18
8
268 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
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.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 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

15 Experts available now in Live!

Get 1:1 Help Now