Hi everyone,
With Spring-WS I cannot send large attachments from the client.
I have a Spring-WS web service for receiving files, and with an Axis2 client I have succesfully sent 900mb to it, without even tweaking java's memory-params. But, because we use Spring throughout the application, I want to make it work with a Spring-WS client.
So far, my Spring-WS client crashes with OutOfMemoryError even at 15mb. That is probably because enabling MTOM does not work. With an attachment of 1.2mb TCPMon reveals that my attachment is just base64 encoded within the message.
I had hoped that setting <property name="mtomEnabled" value="true" /> in the marshaller would make it work.
Is this the fault of Spring-WS, or of my code?
WsTest.java:
applicationContext.xmlCode:public class WsTest { WebServiceTemplate webServiceTemplate; public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) { this.webServiceTemplate = webServiceTemplate; } public void sendFile() { SendRequest sendRequest = new SendRequest(); DataSource messageDataSource = new FileDataSource("d:/temp/YaBB_2.2.1.zip"); sendRequest.setMessage(new DataHandler(messageDataSource)); this.webServiceTemplate.marshalSendAndReceive("my.first.namespace", sendRequest); } public static void main(String[] args) { WsTest wsTest = (WsTest) new ClassPathXmlApplicationContext("applicationContext.xml").getBean("wstest"); wsTest.sendFile(); } }
xsd on which the Jaxb2 classes are based:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="notallowedtoposturls" xmlns:xsi="notallowedtoposturls" xsi:schemaLocation=" notallowedtoposturls"> <bean id="wstest" class="mtomtest.WsTest"> <property name="webServiceTemplate"> <bean class="org.springframework.ws.client.core.WebServiceTemplate"> <property name="messageFactory"> <bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory"/> </property> <property name="marshaller" ref="marshaller" /> <property name="unmarshaller" ref="unmarshaller" /> </bean> </property> </bean> <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <value>mtomtest.SendRequest</value> </list> </property> <property name="mtomEnabled" value="true" /> </bean> <bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <value>mtomtest.SendResponse</value> </list> </property> </bean> </beans>
Thanks,Code:<xs:element name="SendRequest"> <xs:complexType> <xs:sequence> <!-- some string fields... --> <xs:element name="message" type="xs:base64Binary" xmime:expectedContentTypes="*/*" /> </xs:sequence> </xs:complexType> </xs:element>
Sander Hartogensis


Reply With Quote
