Both service providers and consumers must have the MTOM optimizations enabled. The JAX-WS APIs offer different mechanisms for each type of endpoint.
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 the
Endpoint
object is when you publish the endpoint. For more information see Publishing a Service in Developing Applications Using JAX-WS.Get the SOAP binding from the
Endpoint
using itsgetBinding()
method, as shown in Example 5.4.Example 5.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 a
SOAPBinding
object to access the MTOM property.Set the binding's MTOM enabled property to
true
using the binding'ssetMTOMEnabled()
method, as shown in Example 5.5.
To MTOM enable a JAX-WS consumer you must do the following:
Cast the consumer's proxy to a
BindingProvider
object.Tip For information on getting a consumer proxy see Developing a Consumer Without a WSDL Contract in Developing Applications Using JAX-WS or Developing a Consumer From a WSDL Contract in Developing Applications Using JAX-WS.
Get the SOAP binding from the
BindingProvider
using itsgetBinding()
method, as shown in Example 5.6.Example 5.6. Getting a SOAP Binding from a
BindingProvider
// BindingProvider bp declared previously SOAPBinding binding = (SOAPBinding)bp.getBinding();
Set the bindings MTOM enabled property to
true
using the binding'ssetMTOMEnabled()
method, as shown in Example 5.7.