从其他 PC 和 Unix 与 WCF windows 服务交互的最佳方式?
您好,我想创建一个 Windows 服务,与连接到台式电脑的低速 USB 硬件进行通信。
我希望 Windows 服务的方法可以从该 PC 上的其他软件以及 LAN 上的其他 PC/Unix 客户端调用。
考虑到数据的低速特性(只是偶尔对 USB 设备的进度进行状态请求) - 为此使用默认的 http WCF 绑定是否有意义,或者我应该为此查看 TCP 绑定或套接字吗?
非常感谢
Hi I want to create a windows service that speaks to a low speed peice of USB hardware connected to a desktop PC.
I would like the windows service's methods to be callable from other software on that PC, and other PCs/ Unix clients on the LAN.
Given the low speed nature of the data (just occasional staus requests of progress of the USB device ) - does it make sense to use a default http WCF binding for this or should I be looking at TCP binding or sockets for this?
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您可以创建一个 httplistener 并拦截对其发送或接收数据的请求。
该解决方案的强大之处在于,http 几乎是通用的,任何其他计算机都能够向您的服务发送请求。
[编辑]或者您可以出于同样的原因使用restful wcf服务(但客户端必须处理xml)
maybe you can create an httplistener and intercept request to it to send or receive data.
the power of this solution is that http is nearly universal and any other computer will be able to send request to your service.
[edit] or you can use a restful wcf service for the same reason (but clients will have to deal with xml)
我会选择 net tcp 绑定,因为它是针对跨机器通信而设计和优化的,具有二进制消息编码。 http 会更加灵活并且可以跨客户端评估。您甚至可以在没有特殊客户端设置的情况下调用您的服务。
I would go for a net tcp binding, as it's designed and optimzed for cross-machine communications, with binary message encoding. http would be more flexable and cross client assessable. you could even call your services with no special client setup.
为什么要将自己限制在一种绑定上?您可以轻松地公开多个端点,即 LAN 上其他 Windows 客户端的 NetTcp 端点(这比通过 HTTP 协议进行通信更快);网络上非 Windows 客户端的 BasicHttp 端点;对于同一台计算机上的其他服务,您甚至可以公开 NamedPipes 端点,其速度甚至超过 NetTcp。这就是WCF的魅力!构建一次服务并以您想要的方式公开 :-D
但请注意,如果您选择使用 IIS7 托管服务,那么无论您使用 NamedPipes/NetTcp/BasicHttp 端点,都不会产生任何性能差异,因为无论如何,一切都必须通过 HTTP 。
Why limit yourself to one binding? You can easily expose multiple endpoints, a NetTcp endpoint for other windows clients on the LAN (which are faster than communicating via the HTTP protocol); a BasicHttp endpoint for non-windows clients on the network; for other services on the same machine you can even expose a NamedPipes endpoints which even beats NetTcp on speed. That's the beauty of WCF! Build the service once and expose however you want :-D
Mind you though, if you choose to host your service with IIS7 it wouldn't make any performance difference whether you use NamedPipes/NetTcp/BasicHttp endpoints as everything have to go through HTTP anyway.