Question

Is it possible to create a C# EXE or Windows Service that can process Web Service requests? Obviously, some sort of embedded, probably limited, web server would have to be part of the EXE/service. The EXE/service would not have to rely on IIS being installed. Preferably, the embedded web service could handle HTTPS/SSL type connections.

The scenario is this: customer wants to install a small agent (a windows service) on their corporate machines. The agent would have two primary tasks: 1) monitor the system over time and gather certain pieces of data and 2) respond to web service requests (SOAP -v- REST is still be haggled about) for data gathering or system change purposes. The customer likes the idea of web service APIs so that any number of clients (in any language) can be written to tap into the various agents running on the corporate machines. They want the installation to be relatively painless (install .NET, some assemblies, a service, modify the Windows firewall, start the service) without requiring IIS to be installed and configured.

I know that I can do this with Delphi. But the customer would prefer to have this done in C# if possible.

Any suggestions?

Was it helpful?

Solution

Yes, it's possible, you may want to have a look at WCF and Self Hosting.

OTHER TIPS

Yes, it is possible (and fairly easy).

Here is a CodeProject article showing how to make a basic HTTP server in C#. This could easily be put in a standalone EXE or service, and used as a web service.

One technology you might want to check out is WCF. WCF can be a bit of a pain to get into but there's a great screencast over at DNRTV by Keith Elder that shows how to get started with WCF in a very simple fashion.

http://www.dnrtv.com/default.aspx?showNum=135

You could take a look at HttpListener in the .Net framework.

I would highly recommend WCF. It would fit very well into a product like you are describing. There are a good number of books available.

Sure, you can do that. Be sure to change the Output Type of the project to Console Application. Then, in your Main function, add a string[] parameter. Off of some switch that you receive on the command line, you can branch to ServiceBase.Run to run as a Windows Service or branch to some other code to run a console application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top