CodeProject
In this post we will cover
- What is MTOM Encoding
- MTOM Vs Text Encoding
- Reasons to choose MTOM
- Demo
MTOM (Message Transmission Optimization Mechanism) – WCF supports 3 encodings (in context of WCF, encoding means converting a WCF message (serialized XML InfoSet) into bytes) – Text, MTOM & Binary. All Http Bindings (Basic, WS, Dual, etc.) support Text / MTOM encoding, Text being the default one.
Why MTOM?
Problem with Text Encoding is it uses base 64 encoding format which can inflate the message size by 30%. This can be a heavy penalty while carrying large binary attachments.
On the otherhand, MTOM avoids base 64 encoding for binary attachments keeping the overall size of message in control. Moreover, MTOM is based on open specifications & hence is largely interoperable.
Enough of theory... Let's do a demo to concretize the concept.
For this, i have created a simple WCF service. Below image will describe what we intend to do.