Webservice mtom concept

The basic concept of MTOM

MTOM (Message Transmission Optimization Mechanism) message optimization transmission mechanism. 

The model it proposes is suitable for the interaction of large amounts of data. A solution to the overhead caused by Base64 encoding. When the amount of data is small, SOAP still uses XML for message delivery.

The Message Transmission Optimization Mechanism (MTOM) standard allows the large data elements contained in a message to be externalized and transmitted with the message as binary data without any special encoding. The MTOM message will be packaged into a multi-part/related MIME sequence and sent together in the SOAP message.

However, in the case of a large amount of data, if the data is still Base64 encoded, it will bring 33% additional overhead. Such a situation is intolerable for large amounts of data exchange. MTOM is an improvement method proposed on the basis of SOAP message transmission. For the transmission of large amounts of data, Base64 encoding will not be carried out, but directly encapsulated in the MIME part of the SOAP message in the form of the original binary data of the attachment for transmission. The SOAP message refers to the binary content by pointing to the MIME part sent with it, and also includes the basic SOAP XML data, which is still Base64 encoded. Because this model is basically the same as the Simple Mail Protocol SMTP model.

MTOM improves the efficiency of data processing and transmission by simplifying the encoding process of large amounts of data. Because of necessary information such as SOAP messages, MTOM also has some necessary overhead. MTOM can only show its advantages when the size of the binary data element exceeds about 1 KB.

BASE64 encoding

The principle of BASE64 encoding is very simple. The method is to take 6 bits of the input data stream at a time (each bit represents 1 bit of binary), and add 0 if it is less than 6 bits. In this way, every 3 8-bit bytes will be encoded into 4 6-bit bytes (3×8 → 4×6); those less than 4 bytes are filled with “=”. In fact, these 4 six-bit bytes are still 8 bits, but the upper two bits are set to 0. When only 6 bits of a byte are valid, its value space is 0 to the 6th power of 2 minus 1, which is 63, that is to say, the value space of each code of the converted Base64 code is (0~63) .

In this way, 3 8-bit bytes can be converted into 4 bytes, and the 4 converted bytes can be mapped to characters. That is to say, the data can be replaced by character encoding. Because the converted string is one byte longer than the original, and 1/3 longer. Therefore, the length of the encoded data is increased to 4/3 times. This is also the reason why the efficiency of using SOAP messages is lower than that of MTOM. Because SOAP uses XML language for message transmission, XML is a language based on BASE64 encoding.

MIME: Multipurpose Internet Mail Extentions

MIME stands for Multipurpose Internet Mail Extentions. MIME expands the basic text-oriented Internet mail system so that binary attachments can be included in messages to create file format specifications for e-mail exchanges, network documents, and other applications on corporate networks and the Internet.

Leave a Comment

Your email address will not be published.