Jay
Jay

Reputation:

Calling Windows Service from a Web Service

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 :)

Upvotes: 2

Views: 3717

Answers (6)

MattH
MattH

Reputation: 1975

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

Upvotes: 0

John Saunders
John Saunders

Reputation: 161773

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.

Upvotes: 2

lsalamon
lsalamon

Reputation: 8164

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

Upvotes: -1

Sascha
Sascha

Reputation: 10347

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.

Upvotes: 0

Charlie Flowers
Charlie Flowers

Reputation: 17427

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.

Upvotes: 2

bdd
bdd

Reputation: 3434

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.

Upvotes: 2

Related Questions