LibraryToggle FramesPrintFeedback

Using JAX-WS APIs

Overview

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

If you published your service provider using the JAX-WS APIs you enable the runtime's MTOM support as follows:

  1. 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.

  2. Get the SOAP binding from the Endpoint using its getBinding() method, as shown in Example 16.

    Example 16. 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.

  3. Set the binding's MTOM enabled property to true using the binding's setMTOMEnabled() method, as shown in Example 17.

    Example 17. Setting a Service Provider's MTOM Enabled Property

    binding.setMTOMEnabled(true);

Consumer

To MTOM enable a JAX-WS consumer you must do the following:

  1. Cast the consumer's proxy to a BindingProvider object.

    [Tip]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.

  2. Get the SOAP binding from the BindingProvider using its getBinding() method, as shown in Example 18.

    Example 18. Getting a SOAP Binding from a BindingProvider

    // BindingProvider bp declared previously
    SOAPBinding binding = (SOAPBinding)bp.getBinding();

  3. Set the bindings MTOM enabled property to true using the binding's setMTOMEnabled() method, as shown in Example 19.

    Example 19. Setting a Consumer's MTOM Enabled Property

    binding.setMTOMEnabled(true);

Comments powered by Disqus