5

I would like to send large files from the server to the client using MTOM and Spring WS. I realize that this isn't the best approach for this type of thing, but it's a requirement. I have MTOM set up and it works great for small files around 50mb. I am experiencing out of memory errors for larger files and by changing different heap space sizes, I can send slightly larger files, but nothing close to 1gb. 1GB is my test case for this. How can I stream or chunk the MTOM service from the server to the client? I am using Java 6 update 17, Tomcat 6, and Spring WS 1.5.7 with the SaajSoapMessageFactory.

I found an example of streaming with jax-ws, but I'm not sure how to incorporate this into a Spring WS endpoint.

Optimizing Binary Data Transmission Using MTOM/XOP

Dan Polites
  • 6,750
  • 10
  • 50
  • 56

1 Answers1

5

Yesterday, I am having the same problem with uploading large files. Finally I was able to find the solution for that. Spring WS has an customized Axiom message factory called org.springframework.ws.soap.axiom.AxiomSoapMessageFactory which can use file instead of in memory while uploading large files. The only change to do in your configuration is define the bean with your custom properties.

<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
    <property name="payloadCaching" value="false" />
    <property name="attachmentCaching" value="true" />
    <property name="attachmentCacheThreshold" value="1024"/>
</bean>

Once you have this configuration and Axiom classes available in classpath, Spring-ws automatically uses temporary files to piggy back large document uploads.

Teja Kantamneni
  • 17,402
  • 12
  • 56
  • 86
  • I used Axis2 1.5.1 to solve my problem on the client side. I believe it uses axiom as well. – Dan Polites Sep 29 '10 at 13:33
  • What is the best combination/approach for large file upload using MTOM and spring and websphere? SAAJ or AXIOM or JAX-WS or CXF or http client? or is there any other better? Better is in terms of performance, memory usage, time taken to upload. @DanPolites – AJJ Jul 13 '16 at 03:44
  • please expand on this, could you provide an example for the client side uploading – yolob 21 Apr 28 '20 at 09:32