1
votes

I would be grateful if somebody can shed some light on this:

I want to upload binary data via Mtom to a service.

If I configure the endpoint binding with:

<wsHttpBinding>
    <binding name="WsHttpMtomBinding" messageEncoding="Mtom" />

Mtom works - I can see in Fiddler that the binary content is send with Mtom.

If I configure it with:

 <basicHttpBinding>
    <binding name="WsHttpMtomBinding" messageEncoding="Mtom" />

It gets base64 encoded if I look on Fiddler what is send.

I read that WCF does base64 encoding if the message size is smaller than a certain size. I made sure the binary content is big enough. I must use basicHttpBinding because the service is not under my control.

Why is it getting base64 encoded?

1

1 Answers

4
votes

Found the problem: The problem was the WSDL supplied to me. The type in the WSDL was set to HexBinary and not Base64Binary. WCF will only recognize base64 to optimize with MTOM. On top of that it will not use MTOM if the binary data is below 1024 bytes. (The header of the message will still show it is MTOM though)

Excerpt from MSDN: "The purpose of MTOM is to encode a SOAP message to optimize base64-encoded data. The following is a list of constraints: R4151: Any element information item that contains base64-encoded data may be optimized.

B4152: WCF optimizes element information items that contain base64-encoded data and exceed 1024 bytes in length."

Hope this helps somebody. Took my hours of to figure this out.