Reputation: 670
I'm developing a WCF service to send and receive files using MTOM encoding. I have everything up and running with the following configuration.
<customBinding>
<binding name="<omitted>">
<mtomMessageEncoding messageVersion="Soap12" />
<httpTransport maxReceivedMessageSize="2097152" />
</binding>
</customBinding>
However, if the file I send is smaller than 768 bytes, then instead of using MTOM encoding, the file is encoded using Base64 and sent as part of the message itself.
Does anyone know how to force WCF to use MTOM encoding for files smaller than 768 bytes?
Upvotes: 1
Views: 771
Reputation: 151594
From the WCF forum on MSDN: Force WCF to use MTOM "optimization" for small messages:
I think the current minimum size required for binary data to be included as xop instead of base64 encoding is 768 bytes. This is pretty much hardcoded in the XmlMtomWriter class used by the MtomMessageEncoder. And what more XMLMtomWriter is an internal class to System.Xml assembly and you can't extend this class to remove this limit.
From source:
internal class XmlMtomWriter : XmlDictionaryWriter, IXmlMtomWriterInitializer
{
private const int MaxInlinedBytes = 767;
But it doesn't even appear to be used in that class.
Upvotes: 2