Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between MTOM and the attachment features provided by SAAJ?

SAAJ: SOAP with Attachments API for Java

MTOM: SOAP Message Transmission Optimization Mechanism

My simple understanding: they deal with SOAP attachments, with MTOM being the more optimized version of SAAJ. Is this correct?

Are they simply 2 different ways of doing the same thing? Or am I trying to compare apples and oranges here?

Can I use SAAJ and MTOM together?

like image 765
Jops Avatar asked Mar 18 '13 15:03

Jops


1 Answers

It is a little bit more complicated. SAAJ is an old Java API for used to manipulate SOAP envelopes, so sending binary attachments can be done in a sane way (that is not as a BASE64 encoded string in message body). SAAJ is a sort of low level interface, you need to construct SOAP envelope "by hand" in your code and add attachments to it.

If you don't need to work with legacy code and you want to work directly with SOAP envelopes, then look on JAX-WS Dispatcher and Provider interfaces.

MTOM is a another beast. It is not a full web service API - it is specialized way of sending attachments. It can be used by any "true" web service API like JAX-WS or SAAJ (if you manage to force SAAJ to work that way).

MTOM is (almost) always used with XOP, a more efficient way to send binary data, as compared to BASE64 (which has large overhead). Attachment is sent separately as MIME attachment and the MIME type is handled properly (that used to be an issue for Java-Microsoft technologies interactions).

Nowdays forget about SAAJ, use JAX-WS + MTOM support which is provided by most JAX-WS implementations.

like image 166
Piotr Kochański Avatar answered Oct 06 '22 01:10

Piotr Kochański