Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.9.3. Enabling MTOM
By default the Apache CXF runtime does not enable MTOM support. It sends all binary data as either part of the normal SOAP message or as an unoptimized attachment. You can activate MTOM support either programmatically or through the use of configuration.
9.3.1. Using JAX-WS APIs Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Both service providers and consumers must have the MTOM optimizations enabled. The JAX-WS APIs offer different mechanisms for each type of endpoint.
Service provider Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
If you published your service provider using the JAX-WS APIs you enable the runtime's MTOM support as follows:
- Access the
Endpoint
object for your published service.The easiest way to access theEndpoint
object is when you publish the endpoint. For more information see Chapter 31, Publishing a Service. - Get the SOAP binding from the
Endpoint
using 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();
// Endpoint ep is declared previously SOAPBinding binding = (SOAPBinding)ep.getBinding();
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must cast the returned binding object to aSOAPBinding
object to access the MTOM property. - Set the binding's MTOM enabled property to
true
using 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);
binding.setMTOMEnabled(true);
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Consumer Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To MTOM enable a JAX-WS consumer you must do the following:
- Cast the consumer's proxy to a
BindingProvider
object.TipFor information on getting a consumer proxy see Chapter 25, Developing a Consumer Without a WSDL Contract or Chapter 28, Developing a Consumer From a WSDL Contract. - Get the SOAP binding from the
BindingProvider
using 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();
// BindingProvider bp declared previously SOAPBinding binding = (SOAPBinding)bp.getBinding();
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set the bindings MTOM enabled property to
true
using 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);
binding.setMTOMEnabled(true);
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.3.2. Using configuration Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
If you publish your service using XML, such as when deploying to a container, you can enable your endpoint's MTOM support in the endpoint's configuration file. For more information on configuring endpoint's see Part IV, “Configuring Web Service Endpoints”.
Procedure Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The MTOM property is set inside the
jaxws:endpoint
element for your endpoint. To enable MTOM do the following:
- Add a
jaxws:property
child element to the endpoint'sjaxws:endpoint
element. - Add a
entry
child element to thejaxws:property
element. - Set the
entry
element'skey
attribute tomtom-enabled
. - Set the
entry
element'svalue
attribute totrue
.
Example Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Example 9.8, “Configuration for Enabling MTOM” shows an endpoint that is MTOM enabled.
Example 9.8. Configuration for Enabling MTOM