Transferring binary data with MTOM encoding
For Web Services/WCF services that use SOAP XML as the natural message format, binary data in service operations will be transferred as the Base64-encoded string over the transport layer. This is not quite efficient for binary data transfer, as the encoded Base64 string will increase the data size compared to raw binary bytes. Fortunately, WCF supports the MTOM message encoding that can help transfer binary data as their raw bytes within a standard SOAP envelope.
In this recipe, we will use a sample service to demonstrate the steps necessary for applying MTOM message encoding for WCF service endpoints.
Getting ready
Most of the HTTP-based WCF built-in bindings support the MTOM encoding format. A detailed list is provided in the MSDN WCF Binding description at:
System-Provided Bindings
How to do it...
Make
ServiceContract
MTOM ready.The first thing to do is to define a
ServiceContract
type, which...