0

I have a simple self-hosted WCF web service and client and I'm trying to get them to use MTOM for sending and receiving files, specifically images. I checked the Microsoft samples and basically, all they do is setting the config files for the binding to use MTOM as the MessageEncoding. I did this also, and followed plenty of tutorials and articles, and if I check the

(selfHost.Description.Endpoints[0].Binding as WSHttpBinding).MessageEncoding property at runtime, it is MTOM as I would expect. However, when I inspect my client's sent and received messages by implementing and IClientMEssageInspector, I see they are sent as normal text soap messages. I can see the huge base64 string in the message inside an <Image> node. When I inspect the Microsoft MTOM sample client's messages after sending the same file, there is no base64 string and the request's body just shows
<s:Body>... secuencia ...</s:Body> (I guess in english it would say 'sequence').

I don't know what to do to make it work properly. I have tried different file sizes, from a few KB to almost 2MB. I have tried setting the MEssageEncoding via code instead of config files and still no luck.

Do you have any ideas of why it might not be working? Let me know if you need any more information about the problem.

Thanks in advance.

Alex Terreaux
  • 1,881
  • 5
  • 23
  • 39

1 Answers1

0

when you create the

<binding name="mybindingname" messageEncoding="MTOM" ...>,

did you add the binding name to your service like below?

<service>
<endPoint bindingConfiguration="mybindingname" ... />

Yang You
  • 2,618
  • 1
  • 25
  • 32