9.3. Enabling MTOM
9.3.1. Using JAX-WS APIs
Overview
Service provider
- Access the
Endpointobject for your published service.The easiest way to access theEndpointobject is when you publish the endpoint. For more information see Chapter 29, Publishing a Service. - Get the SOAP binding from the
Endpointusing itsgetBinding()method, as shown in Example 9.4, “Getting the SOAP Binding from an Endpoint”.Example 9.4. Getting the SOAP Binding from an Endpoint
// Endpoint ep is declared previously SOAPBinding binding = (SOAPBinding)ep.getBinding();
You must cast the returned binding object to aSOAPBindingobject to access the MTOM property. - Set the binding's MTOM enabled property to
trueusing the binding'ssetMTOMEnabled()method, as shown in Example 9.5, “Setting a Service Provider's MTOM Enabled Property”.Example 9.5. Setting a Service Provider's MTOM Enabled Property
binding.setMTOMEnabled(true);
Consumer
- Cast the consumer's proxy to a
BindingProviderobject.TipFor information on getting a consumer proxy see Chapter 23, Developing a Consumer Without a WSDL Contract or Chapter 26, Developing a Consumer From a WSDL Contract. - Get the SOAP binding from the
BindingProviderusing itsgetBinding()method, as shown in Example 9.6, “Getting a SOAP Binding from aBindingProvider”.Example 9.6. Getting a SOAP Binding from a
BindingProvider// BindingProvider bp declared previously SOAPBinding binding = (SOAPBinding)bp.getBinding();
- Set the bindings MTOM enabled property to
trueusing the binding'ssetMTOMEnabled()method, as shown in Example 9.7, “Setting a Consumer's MTOM Enabled Property”.Example 9.7. Setting a Consumer's MTOM Enabled Property
binding.setMTOMEnabled(true);
9.3.2. Using configuration
Overview
Procedure
jaxws:endpoint element for your endpoint. To enable MTOM do the following:
- Add a
jaxws:propertychild element to the endpoint'sjaxws:endpointelement. - Add a
entrychild element to thejaxws:propertyelement. - Set the
entryelement'skeyattribute tomtom-enabled. - Set the
entryelement'svalueattribute totrue.
Example
Example 9.8. Configuration for Enabling MTOM
<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="xRayStorage"
implementor="demo.spring.xRayStorImpl"
address="http://localhost/xRayStorage">
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
</beans>
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.