title: How does MTOM work + sample code
body: <p>I am trying to make a very simple web-service which does the following:</p>
  
  <ol>
  <li>The client hits the web service requesting a file.</li>
  <li>The web service's service class queries a hashtable which has the key (search query) and the value as the base64encoded value of a file (say a pdf)</li>
  <li>Now,I need to use MTOM to return the base64encoded value stored in the hashtable to the client.</li>
  </ol>
  
  <p>It's upto the client to decode it and convert it to pdf.</p>
  
  <p>So, here are my questions:</p>
  
  <ol>
  <li><p>I understand we encode files to base64 for transmission via web service, but where and how does MTOM come into the picture there?</p></li>
  <li><p>Can some one provide me a simple method which uses MTOM and sends the data back. Do we need to specify something in the WSDL too? or a simple String return type would suffice? Why/Why not?</p></li>
  </ol>
  
  <p>Thanks</p>
  
  <p>I have seen this <a href="https://stackoverflow.com/questions/1113656/jax-ws-mtom-sample-code-service-client-need-simple-one">code</a>. It uses a lot of annotations, I just need a simple java code using MTOM. New to J2EE HERE :)</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>Decent enough explanation <a href="https://stackoverflow.com/questions/215741/how-does-mtom-work">here</a>, now I need to understand it from the implementation level.
  Good info <a href="http://www.crosschecknet.com/intro_to_mtom.php" rel="nofollow noreferrer">here</a>, but for .Net</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>What should be the return type of the method "createMTOM(int id)"??</p>