简体   繁体   中英

How to expose restful interface from windows service ?

I wrote a wcf service that expose restful interface.
Now i using the iis as the wcf service host.

There are some action that i need to make on my application beside the exposing of the restful - and for this need i must run my application as a windows service. But the using the iis as a host will not make my wcf server run as a service.

How to make it possible to using a windows service with expose wcf restful interface service ?

您可以自托管WCF服务,请参阅ServiceHost

To be able to run the app in 2 different host models, you have to separate hosting stuff from you main code. The key point of it: you can use controllers created in the other library project.

I did this before:

  1. Create a library project and move all you controllers and other classes there.
  2. Create empty WFC service, add reference to the lib above and make it working.
  3. Create an empty console app, reference to the lib, add self hosting stuff and make it working.
  4. Add topshelf package to console app to be able to install it as windows service.

So you will get:

  1. building and deploying WCF project you can host it in IIS;
  2. building a console app you can run it as console app;
  3. using topshelf install param you can install a console app as windows service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM