Skip to main content

MTOM in JAXWS 2.0 RI EA3

Posted by vivekp on January 17, 2006 at 5:52 PM PST

MTOM support has been there since JAX-WS 2.0 EA2 release.
There are 2 ways you can try it - join the

jax-ws
 project on
java.net
and get the jaxws

distribution
or you can install

JWSDP 2.0
.



By default MTOM encoding is disabled. To enable MTOM on a service all you need to do is to add enable-mtom attribute on the endpoint descriptor element.



Here is a sample descriptor from the mtom sample:

<p>&lt;endpoints xmlns='<a href="http://java.sun.com/xml/ns/jax-ws/ri/runtime'%20version='2.0'">http://java.sun.com/xml/ns/jax-ws/ri/runtime' 
version='2.0'</a>&gt;<br>&nbsp;&nbsp;&nbsp;
&lt;endpoint<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
name=&quot;Mtom&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
implementation=&quot;mtom.server.HelloImpl&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
wsdl=&quot;WEB-INF/wsdl/hello.wsdl&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
service='{<a href="http://example.org/mtom}HelloService">http://example.org/mtom}HelloService</a>'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
port='{<a href="http://example.org/mtom}HelloPort">http://example.org/mtom}HelloPort</a>'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
url-pattern=&quot;/hello&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>enable-mtom</b>=&quot;true&quot; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>mtom-threshold-value</b>="0"/&gt;<br>&lt;/endpoints&gt;</p>

On the client side, you can use SOAPBinding.setMTOMEnable(). For example,
Object port = new HelloService().getHelloPort ();<br>
<br>
//get the binding and enable mtom<br>
SOAPBinding binding = (SOAPBinding)((BindingProvider)port).getBinding ();<br>
binding.<b>setMTOMEnabled</b> (true);

Thats pretty much what you need to do to enable MTOM.  For details see the


MTOM online documentation
in

jaxws-ws
project on
java.net
. to try the sample,
assuming you have JWSDP 2.0 installed with S1AS 8.2_02, try the mtom samples:
$JWSDP_HOME/jaxws/samples/mtom
and $JWSDP_HOME/jaxws/mtom-soap12.
Here $JWSDP_HOME is where you installed JWSDP 2.0.

You can post your queries to
jax-ws dev
mailing alias.


Related Topics >>