views:

622

answers:

6

I am using .Net 2.0 framework and would like to call a function in Windows service from a web service. Is this possible? And If yes, how much control I will have over the function i.e passing parameters, getting the result back etc. Any ideas would be greatly appreciated :)

A: 

Remoting is your best option if you need to pass parameter values.

If you don't need to share objects or anything too complex, ServiceController is probably easier.

Paperino
+2  A: 

You can do it through .NET remoting. If you go that route, it will appear you are calling a method and getting a result, but all your parameters will be serialized over the wire, and the result will be serialized back. Therefore, everything must be made serializable.

Charlie Flowers
A: 

You could implement a basic http server that maps certain requests to functions. Query-string will be mapped to parameters. Actually not hard and I have done this in the past (as I provided some rudimentary template-based reporting). It wasn't dynamically, but it could be done dynamically. Look at HttpListener for a starting point. You could as well host the asp.net engine in it.

It has it advantages and disadvantages.

Sascha
A: 

Create service project what export an interface COM or use PIPE to transfer data. View this Interprocess Communication using Named Pipes in C#

lsalamon
A: 

How about hosting a WCF service inside of the Windows Service. You can use net.tcp or named pipes to communicate between "your" web service and the one in the Windows Service. You can use the NetDataContractSerializer for serialization with type fidelity.

John Saunders
A: 

Why not package the function in its own DLL then distribute it with the Windows Service and the Web Service separately?

MattH