I have written a simple upload service with JAX-WS RI. Classes are generated with DataHandler
type by XJC. At coding time @MTOM
and @StreamingAttachment
are added to the service implementation. Now when a client, a .NET client, sends the uploaded data with MTOM multipart/related
and data is received but the data source in the data handler is com.sun.istack.ByteArrayDataSource
and java.io.ByteArrayInputStream
. This means that the stream from the client is fully consumed into memory. With larger files, the memory explodes.
After a few googling researches I haven't found anything but some SO questions regarding SOAP handlers which I do not have. No success yet.
I started a debugging session and figured out that the data internally is contained in a StreamingDataHandler
which is the recommended way but the MtomCodec
queries the length of the attachment and causes the underlying data object to fully consume the input stream into memory. End of story.
This seems pretty brain-dead to me because the entire optimization from MTOM is completely gone.
Does anyone know a solution to this? Otherwise the entire approach in JAX-WS RI seems to be useless, I have to resort to REST.
This might be a duplicate of MTOM not working when using SOAPHandler. The outcome is the same.
For what it's worth, I am on:
- Tomcat 6.0.41
- Java 7
- JAXB 2.2.11
- JAX-WS 2.2.10