开发者

Need a step-by-step WCF as Windows Service

I'm trying to find a (good) step-by-step example of creating a WCF and hosting it as a Windows Service (with installer). I'm using VS2010 and have a simple WCF with 1 function (ju开发者_开发问答st returns 'Hello').

Please don't Google and post; I'm looking for a resource someone has actually used. Most of the Googling I've done hasn't turned up much for what I'm trying to do.

I just want to take my WCF library, and find a way to install it as a Window Service. I've done it in 2008, but 2010 is... Different.


For future reference - for anyone else looking at this thread:

Here is the best example I've found for what this question was looking for: CodeProject: WCF Service with Windows Service Hosting, consumed from C# App!

This link mentioned above shows how to consume the WCF service, but with a lot of other stuff to wade through: MSDN: How to: Host a WCF Service in a Managed Windows Service!

This second link above is good for creating the WCF service, but not for consuming it: MSDN: Hosting and Consuming WCF Services!

I rarely find MSDN articles that I like :-)


You just need to host the wcf contract class in your onstart method of service calling ServiceHost host = new ServiceHost(YourClass) and in onclose method of your service you need call host.close(). The hosting option depends on what type of clients you want to talk to if you want to talk to pure html clients using REST you need to host your service in WebServiceHost and the binding you need to use in that case is webHttpBinding.

I have followed the following example and was able to create windows service hosted wcf and im sure this what you are looking for link

I did not find any difference in creating wcf service in vs2008 and vs2010.

What type of clients do you want to talk and which protocols do you want to support. This all defines your configuration.


What I've used when I use WCF in a Windows Service is Topshelf as a Windows service framework and a modified version of this Code Project code to dynamically host, install and run WCF services.

Topshelf makes it very easy to develop and debug because it can be run as a console application. Being able to dynamically update WCF service libraries without stopping the Windows service is just cool. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜