I get it. First of all, I was incorrect when I said that I was getting the first part of a message with several parts using the MTOM encoder; I got it. I looked at it in the debugger, and the bottom should be trimmed in the debug viewer. Note this to my inexperience by manually looking and decrypting frequent messages.
At the second moment, all I had to do was use the MTOM encoder when the Content-Type was multipart / related and everything worked fine. If you read the article mentioned above, all this concerns the dynamic determination of whether the message is plural or plain text, and on the basis of this selects the correct encoder. In fact, it is a custom encoder with a built-in encoding encoder and built-in MTOM codec and switches back and forth based on the type of content of the incoming message.
Our project requires some subsequent processing of the response message before it is passed to the main program logic. Thus, we get the incoming SOAP content as an XML string and do some XML manipulation.
This is a slight deviation from the solution recommended in the article. All that is required in solving the article is reading the message using the correct encoder in System.ServiceModel.Channels.Message and returning it. In our solution, we need to interrupt this process and perform post-processing.
To do this, follow these steps in a custom encoder:
public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType) {
source share