2) Enable MTOM on your service
If you've used JAX-WS to publish your endpoint you can enable MTOM like so:
import javax.xml.ws.Endpoint;
import javax.xml.ws.soap.SOAPBinding;
Endpoint ep = Endpoint.publish("http://localhost/myService",
new MyService());
SOAPBinding binding = (SOAPBinding) ep.getBinding();
binding.setMTOMEnabled(true);
Or, if you used XML to publish your endpoint:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schema/jaxws.xsd">
<jaxws:endpoint
id="helloWorld"
implementor="demo.spring.HelloWorldImpl"
address="http://localhost/HelloWorld">
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
</beans>
If you're using the simple frontend you can set the mtom-enabled property on your ServerFactoryBean or ClientProxyFactoryBean:
Map<String,Object> props = new HashMap<String, Object>();
// Boolean.TRUE or "true" will work as the property value here
props.put("mtom-enabled", Boolean.TRUE);
ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
pf.setPropertyies(props);
...
YourClient client = (YourClient) pf.create();
ServerFactoryBean sf = new ServerFactoryBean();
sf.setPropertyies(props);
...
sf.create();
Similarly, you can use the XML configuration:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:simple="http://cxf.apache.org/simple"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schema/simple.xsd">
<simple:server
id="helloWorld"
serviceClass="demo.spring.HelloWorldImpl"
address="http://localhost/HelloWorld">
<simple:properties>
<entry key="mtom-enabled" value="true"/>
</simple:properties>
</simple:server>
<simple:client
id="helloWorldClient"
serviceClass="demo.spring.HelloWorldImpl"
address="http://localhost/HelloWorld">
<simple:properties>
<entry key="mtom-enabled" value="true"/>
</simple:properties>
</simple:client>
</beans>