views:

27

answers:

2

I have a windows service and I'd like my application to be able to call some methods on that service.

I've read that this is possible via exposing the required methods with WCF.

Can someone give me a pointer on how to achieve this? I understand web services and calling them, but WCF and windows services are less my forte.

+1  A: 

You can host a WCF service within your windows service; and supply an HTTP endpoint if you wish to use it like a web service.

This allows greater control of the windows service instance with WCF

http://msdn.microsoft.com/en-us/library/ms733069.aspx

Gurdas Nijor
+1  A: 

Check out the MSDN developer center on WCF - it gives you a great intro and lots of reference material for WCF.

Basically, what you need to do is create a service contract - an interface that defines your service and its methods. Unless you only work with strings and ints, you will most likely also have to define a data contract - structured classes that will hold your objects going back and forth.

You then need a service implementation in a class that implements that service interface. This class will then be hosted inside your NT Service by means of a ServiceHost (a class from the WCF runtime).

Typically you will define the "endpoints" (the URL's to call into and the protocols to use to do so) in configuration for your service - in this case, in your NT service's app.config.

Once that's all up and running, your outside clients should be able to call into your WCF service running inside a NT Service.

Marc

marc_s