通过 WCF 发送二进制数据:二进制与 MTOM 编码

发布于 2024-11-26 09:19:52 字数 339 浏览 2 评论 0原文

我对 WCF 以及通过 WCF 发送二进制数据的了解有限,所以这个问题可能有点初级。

我想知道使用 BinaryMessageEncodingBindingElementMtomMessageEncodingBindingElement 发送数据之间的区别。在阅读了 MSDN 上的 页面后,我仍然不清楚何时使用哪种方法大数据和流媒体

另外,还有一个小问题:带有附件的消息和 MTOM 消息是同一件事吗?

I have limited knowledge in WCF as well as sending binary data via WCF, so this question may be somewhat rudimental.

I would like to know the difference between sending data with BinaryMessageEncodingBindingElement and MtomMessageEncodingBindingElement. It is still not clear to me when to use which approach after reading this page from MSDN on Large Data and Streaming.

Also, a small question: are a message with attachments and an MTOM message the same thing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稀香 2024-12-03 09:19:52

MTOM 是一种标准,它使用多部分 mime 编码消息来发送较大的消息部分,并且将 Base64 编码为纯二进制的成本太高。 SOAP 消息本身作为消息的初始部分发送,并包含对二进制部分的引用,然后 Web 服务软件堆栈(如 WCF)可以将这些二进制部分拉回到一起以创建消息的单一表示形式。

二进制编码完全是 WCF 专有的,并且实际上不仅仅与大型消息有关。它提供了 XML 信息集的二进制表示形式,与基于文本的格式相比,它在网络上更加紧凑并且解析速度更快。如果您碰巧要发送大型二进制数据块,那么它正好适合正在发送的其他字节。

流式传输可以使用任何消息格式来完成。这更多的是关于数据何时通过网络写入,而不是在呈现给网络传输之前完全缓冲在内存中。较小的消息在发送之前进行缓冲更有意义,而较大的消息(尤其是包含大型二进制块或流的消息)需要进行流式传输,否则会耗尽内存资源。

MTOM is a standard that uses multi-part mime-encoded messages to send portions of the message that are large and would be too expensive to base64 encode as pure binary. The SOAP message itself is sent as the initial part of the message and contains references to the binary parts which a web service software stack like WCF can then pull back together to create a single representation of the message.

Binary encoding is entirely proprietary to WCF and really doesn't just have to do with large messages. It presents a binary representation of the XML Infoset which is far more compact across the wire and faster to parse than text based formats. If you happen to be sending large binary chunks of data then it just fits right in with the other bytes that are being sent.

Streaming can be done used with any message format. That's more about when the data is written across the network vs. being buffered entirely in memoery before being presented to the network transport. Smaller messages make more sense to buffer up before sending and larger messages, especially those containing large binary chunks or streams, necessitate being streamed or will exhaust memory resources.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文