Ivan's
doc is incredible. Lots of details and explanations.
Here is what I have found. Correct me if I make any mistake.
I changed my code to use SAAJ, and the setContent() helps a lot. Normally, in order to create the SOAP message, I had to maintain 2 copies of a
string: one is the Base64 string representing the file, and the other is the Base64 string of the file inside the SOAP message.
If I send a 20Mb
word doc, it is equivalent to 26Mb Base64 string. In order to keep one copy of the 26Mb Base64 string, the heap space grows to around 120Mb.
2 copies will take up 240Mb heap space easily. The setContent() maintains only one copy of the string in form of byte[] and thus reducing the heap space to only 120Mb.
However, 120Mb heap space is till a lot.
The word streaming in SAAJ gives me the impression that I don't have to keep a full copy of the SOAP message in memory and that I can keep the SOAP message in a FileInputStream (or something similar) and send the content of a stream one chunk at a time. So far, it is not the case.
Thanks