在 LAN 中托管 WCF 服务
我有 WCF 服务,允许在 LAN 中的多个用户之间发送消息 - 就像聊天一样。 我应该如何托管它?有什么建议吗? 该服务应该一直启用 我考虑控制台应用程序,但我不确定它是否是最好的解决方案。
I have got WCF service allowing sending messages between several users in LAN - sth like chat.
How should I host it? Any recommandations?
This service just should be enabled all the time
I think about Console Application but I'm not sure if it's the best solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有很多好的选择。正如 Alexander 所说 - IIS 就是其中之一。但这取决于您想用它做什么。
是否有某种类型的服务器应用程序您启动并与之交互,然后将服务托管在其中。
但对我来说,最好的选择通常是将其托管在一个简单的 Windows 服务中。
为此,我在单独的程序集中编写了所需的所有内容,并在测试期间使用控制台应用程序,最后只需将组件插入一个简单的 Windows 服务项目中,然后在某个服务器上安装/运行它。不需要以这种方式运行 IIS。
在这里您可以看到 Windows 服务是如何完成的: 如何:托管 WCF 服务在托管 Windows 服务中
There are a lot of good options. As Alexander said - IIS is one. But it depends on what you want to do with it.
Is there some kind of Server-App you start and interact with then just host the service in there.
But for me the best option is usually to host it inside a simple Windows-Service.
For this I write all that is needed in a seperate assembly and use a console-app during my testing and finally just plug the components inside a simple windows-serivce project and install/run it on some server. No need to have IIS running this way.
Here you can see how the windows-service is done: How to: Host a WCF Service in a Managed Windows Service
如果它需要一直运行,并且在 LAN 环境中工作,我建议:
netTcpBinding
以获得最佳效果速度可能确实没有必要将其放入 IIS - 全天候运行的 Windows 服务就像一个魅力!
请参阅 MSDN 操作方法:在托管应用程序中托管 WCF 服务更详细的建议
If it needs to be up all the time, and works in a LAN environment, I would recommend:
netTcpBinding
to get the best speed possibleThere's really no need to put this into IIS - a Windows Service which runs around the clock works like a charm!
See MSDN How-To: Host a WCF Service in a Managed application for more detailed advice
如果是 WCF 服务,则应将其托管为 WCF 服务,即 IIS 应用程序。
这是一个很好的截屏视频:
http://www.youtube.com/watch?v=mX8quq7MoeI< /a>
If it is WCF service, you should host it as WCF service, namely as IIS application.
Here is good screencast of that:
http://www.youtube.com/watch?v=mX8quq7MoeI
根据 Juval Lowy 的说法,对于 Intranet 场景,托管推荐建议使用以下决策流程图:
也用于关于使用 Windows 服务或控制台应用程序的决定:使用 Windows 服务作为主机在可能的情况下是优选的。
MSDN 中还描述了托管选项,并且有一个表格每个托管选项的优点和缺点,可以帮助您做出决定。
For intranet scenarios the hosting reccomne recommendation is to use the following decision flowchart, according to Juval Lowy:
Also for regarding the decision to use a windows service or a console application: using a windows service as a host is preferable whenere that is posible.
The hosting options are also described in MSDN, and there's a table with advantages and dissadvantage3s of each hosting option, which can help you decide.