简体   繁体   English

在应用程序中托管WCF服务

[英]Host a WCF Service in a Application

I developed a WCF application, and I want to package it in a program which can be installed by normal user without installing Visual Studio or IIS on his machine. 我开发了WCF应用程序,并且希望将其打包在一个程序中,该程序可以由普通用户安装,而无需在其计算机上安装Visual Studio或IIS。

This WCF will be called remotely from another machnine using the machine IP Address. 将使用计算机IP地址从另一个机器远程调用此WCF。

What do you suggest for this case ? 您对此案有何建议?

You could host the WCF service in a console app. 可以在控制台应用程序中托管WCF服务。 The obvious downside to this is that someone would have to start the console app on the host machine first in order for the WCF service to be available remotely. 这样做的明显缺点是,有人必须首先在主机上启动控制台应用程序,才能远程使用WCF服务。 Chances are, you want 24/7/365 access to the WCF service, in which case you'll want to host it in a Windows service if IIS is not an option. 您可能希望24/7/365访问WCF服务,在这种情况下,如果不能选择IIS,则希望将其托管在Windows服务中。 That said, check out this SO question for how to leverage your Windows service as a console application to simplify debugging. 也就是说,请查看此SO问题 ,了解如何利用Windows服务作为控制台应用程序来简化调试。

As to the choice of binding, I have always found this chart helpful. 关于绑定的选择,我总是发现此图表很有帮助。

WCF绑定选择流程图 .

Since you explicitly mentioned using the machine's IP address, I would lean toward NetTcpBinding assuming firewalls are not going to be a problem. 由于您明确提到使用计算机的IP地址,因此我假设防火墙不会成为问题,因此我倾向于使用NetTcpBinding

You can host your WCF Services as a Windows Service, and use the Http Endpoint. 您可以将WCF服务作为Windows服务托管,并使用Http端点。

Also, check this link . 另外,请检查此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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