-2

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
Community
  • 1
  • 1
Michael-O
  • 18,123
  • 6
  • 55
  • 121
  • I have a number of questions about 1) which libraries you're using, 2) your client and server environments, 3) the specific client and/or server errors you're getting. But ... SUGGESTION: See if this link has any useful tips: [Optimizing Binary Data Transmission Using MTOM/XOP](http://docs.oracle.com/cd/E14571_01/web.1111/e13734/mtom.htm#WSADV130). In particular, something like `@StreamingAttachment(parseEagerly=true, memoryThreshold=40000L)` might be applicable. – FoggyDay Feb 17 '15 at 21:01
  • @FoggyDay, 1) versions are stated in the question. 3) client windows, dev machine windows. 3) I get the famous `OutOfMemoryError`. I have read the Oracle article right after my discoveries and applied both annotation the the service implementation class. No change happened. I have added `@StreamingAttachment(parseEagerly=true, memoryThreshold=100_000L)`. The uploded file has 10 MB. – Michael-O Feb 17 '15 at 21:29

1 Answers1

0

After further debugging sessions and searches on the net, I have found several JIRA issues and blog posts that it is plain broken in JAX-WS RI. As soon as you have a handler, you're lost. This applies to outgoing but especially to incoming streams.

At the end, JAX-WS RI is unusable for file interaction. I have to evaluate Apache CXF at some point.

Michael-O
  • 18,123
  • 6
  • 55
  • 121