WCF NetTCPBinding 与 HttpBinding 在线发送数据的差异
假设我有一个暴露两个端点的服务,第一个是 NetTCPBinding,第二个是任何风格的 HttpBinding。他们都实施完全相同的服务合同。
通过线路发送的内容有什么区别?
- 使用 netTcp 我的消息是否仍序列化为 XML?或者我的对象的一些二进制表示?
- 就接收消息而言,有什么区别? http端点是否只理解http命令(get/post等),而nettcp端点理解不同的东西?
- 为什么 nettcp 比 http 更有效(在这种情况下我不需要互操作性) - 开销在哪里?
我认为在所有情况下,在将消息发送到网络之前,它都会被转换为二进制,因此,在网络术语中,http 也位于 tcp 之上 - 因此 http 通信需要额外的地方。
感谢这个问题有点模糊,但希望有人会知道我想问什么:)
Say I have a service exposing two end points, 1st is a NetTCPBinding the second is any flavour of HttpBinding. They both implement exactly the same service contract.
What is the difference in what is sent on the wire?
- Using netTcp is my message still serialised to XML ? Or some binary representation of my objects?
- In terms of what receives the messages what is the difference? Will the http endpoint only understand http commands (get/post etc) where as the nettcp end point understands something different?
- Why is nettcp more efficient (in this case I dont need interoperability) than http - where is the overhead?
I think that in all cases, before the message is put onto the wire it will be converted to binary so, also http sits on top of tcp in networking terms - so somewhere extra is needed for http communications.
Appreciate the question is a bit vague but hopefully someone will know what I am trying to ask :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 WCF 中,特定的绑定并不一定意味着特定的编码。可以配置各种绑定以使用各种编码。 Net.TCP默认使用二进制编码(我认为是MTOM),HTTP默认使用text/xml编码。
使用 net.tcp,您的消息将发送至发送者 -> net.tcp->接收者。对于 HTTP,它们来自发送者 -> http-> TCP-> http->接收者。还有一个额外的层。 tcp 的优点在于:额外层和默认编码。
使用二进制编码的 HTTP 性能接近 net.tcp。
编辑:实际上我认为 Net.TCP 中可能还有其他优化。这是一个WCF-WCF通信场景,因此MS对两端都有控制权。
In WCF a particular binding does not necessarily imply a particular encoding. Various bindings can be configured to use various encodings. Net.TCP uses a binary encoding by default (MTOM I think), and HTTP uses a text/xml encoding by default.
With net.tcp your messages go sender -> net.tcp -> receiver. With HTTP they go from sender -> http -> tcp -> http -> receiver. There's an extra layer. The advantage of tcp is both of those: Both the extra layer and the default encoding.
HTTP with a binary encoding approaches net.tcp performance.
EDIT: Actually I think there may also be other optimizations in Net.TCP. It's a WCF-WCF communication scenario, so MS has control of both ends.