0

I am bit confuse in understanding the concept of MTOM in JAX-WS service . I have a webservice exposing a method that returns an Image . Below is the SIB and publisher code

//@MTOM
@WebService(endpointInterface= "com.test.clear.TestImageInterface")
@BindingType(value = SOAPBinding.SOAP11HTTP_MTOM_BINDING)
public class TestImageImpl implements TestImageInterface{


@WebMethod
@Override
// Create a named image from the raw bytes.
public Image getImageByName(String name) {

    Path path = Paths.get("..\..\..\"+name);

try {

    byte[ ] bytes = Files.readAllBytes(path);
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    Iterator iterators = ImageIO.getImageReadersByFormatName("jpeg");
    ImageReader iterator = (ImageReader) iterators.next();
    ImageInputStream iis = ImageIO.createImageInputStream(in);
    iterator.setInput(iis, true);
    return iterator.read(0);
}
catch(IOException e) {
    System.err.println(e);
return null;
}
}

}

publisher >>

Endpoint.publish("http://localhost:8080/TestWS/getImage", new TestImageImpl());

The confusion i have is to understand when to use @MTOM and when to use @BindingType annotation . If i use either one of the annotation or use both together , i do not see any difference in the WSDL published by the publisher class . Below is the generated WSDL

<wsp:Policy wsu:Id="TestImageImplPortBinding_MTOM_Policy">
<ns1:OptimizedMimeSerialization xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>

<binding name="TestImageImplPortBinding" type="tns:TestImageInterface">
<wsp:PolicyReference URI="#TestImageImplPortBinding_MTOM_Policy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

...
...
</definitions>

Also i do not see any difference in SOAP response got from Service . ie: i got
< Xop:include href:cid / > and got file as attachment in

Does that mean to enable MTOM at server side one can use either one of the annotation ?

I tried to set MTOM programmatically at publisher side after removing both the annotations from SIB like below :

SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);

But then WSDL generated was not having MTOM policy at all.

So when one needs to set MTOM programmatically ?

Can some one explain the working of MIME type and MTOM .

Thanks much in advance .

summary
  • 125
  • 1
  • 14

1 Answers1

0

I have got answer of the above posted question here >> [ http://itdoc.hitachi.co.jp/manuals/3020/30203Y2310e/EY230716.HTM ] [<code>Table-30</code>]1

Thank you everyone .

summary
  • 125
  • 1
  • 14