aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes MTOM and encoded binary data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "MTOM and encoded binary data" Watch "MTOM and encoded binary data" New topic
Author

MTOM and encoded binary data

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 735
On MZ's notes, p. 103, it says "If you want to use MTOM, you should encode your binary data as xs:base64Binary content".
But from Martin Kalin's Web Service Up and Running, p. 118, it says "MTOM optimizes the transmission by avoiding data bloat, but the message receiver is forced to deal with raw bytes."
According to Martin Kalin, when MTOM is enabled, the binary data sent to the receiver is not encoded in base64. But in MZ's notes, the binary data should be encoded.

Are the quoted statements contradicting with each other?


David Lizarraga
Greenhorn

Joined: Feb 11, 2014
Posts: 2
Hi everyone, I am new to the forum although I have been lurking for quite some time now.

First, let me explain in a few words, what's the process that occurs when we are sending an attachment with MTOM.

If you want an attachment to be sent using MTOM, first of all this attachment should be encoded in Base64.
Then before the soap message is sent, MTOM will optimize the message by deciding (based mostly on the data size) if he should convert the data to a MIME attachment or leave it as Base64 encoded data.
If he decides that it is better to send it as a MIME attachment, then an xop element will be placed where the base64Binary element was, pointing to the location of the MIME attachment, which is outside the soap message (but inside the request/response http message).
This MIME attachment will be raw bytes, not Base64 encoded data anymore.

So both of the statements are true:
1. "If you want to use MTOM, you should encode your binary data as xs:base64Binary content". Yes, at first your data will always be encoded as Base64.
2. "MTOM optimizes the transmission by avoiding data bloat, but the message receiver is forced to deal with raw bytes." True but not always. The client will receive raw bytes whenever MTOM decided to send the data as a MIME attachment, and will receive base64Binary content when he decides not to.

Hope it helped.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1661
    
  25

Hi David!

Welcome to CodeRanch and thank you for the nice explanation!

Regards,
Frits
David Lizarraga
Greenhorn

Joined: Feb 11, 2014
Posts: 2
Frits Walraven wrote:Hi David!

Welcome to CodeRanch and thank you for the nice explanation!

Regards,
Frits


Thank you Frits
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MTOM and encoded binary data