WCF NetTCPBinding与HttpBinding的在线发送数据差异 [英] WCF NetTCPBinding vs HttpBinding difference in data sent on wire

查看:116
本文介绍了WCF NetTCPBinding与HttpBinding的在线发送数据差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个公开两个端点的服务,第一个是NetTCPBinding,第二个是HttpBinding的任何形式.他们都执行完全相同的服务合同.

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?

  • 使用netTcp我的消息是否仍序列化为XML?还是我的对象的一些二进制表示形式?
  • 就什么接收消息而言,有什么区别? http端点仅能理解http命令(get/post等),而nettcp端点能理解不同的地方吗?
  • 为什么nettcp比http更有效(在这种情况下,我不需要互操作性)-开销在哪里?

我认为在所有情况下,在将消息放入网络之前,它将被转换为二进制,因此,就网络而言,http也位于tcp的顶部-因此,http通信需要额外的空间.

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 :)

推荐答案

在WCF中,特定的绑定不一定意味着特定的编码.可以将各种绑定配置为使用各种编码. Net.TCP默认情况下使用二进制编码(我认为是MTOM),HTTP默认情况下使用text/xml编码.

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.

使用net.tcp,您的邮件将成为发件人-> net.tcp->收件人.使用HTTP时,它们从发件人-> http-> tcp-> http->接收者发送.有一个额外的层. tcp的优点是两者都有:额外的层和默认编码.

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接近net.tcp性能.

HTTP with a binary encoding approaches net.tcp performance.

实际上,我认为Net.TCP中可能还存在其他优化.这是WCF-WCF通信方案,因此MS可以控制两端.

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.

这篇关于WCF NetTCPBinding与HttpBinding的在线发送数据差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆