title: JAX-WS SoapHandler with large messages: OutOfMemoryError
body: <p>Using JAX-WS 2, I see an issue that others have spoken about as well. The issue is that if a SOAP message is received inside a handler, and that SOAP message is large - whether due to inline SOAP body elements that happen to have lots of content, or due to MTOM attachments - then it is dangerously easy to get an OutOfMemoryError.</p>
  
  <p>The reason is that the call to getMessage() seems to set off a chain of events that involve reading the entire SOAP message on the wire, and creating an object (or objects) representing what was on the wire.</p>
  
  <p>For example:</p>
  
  <pre><code>...
  public boolean handleMessage(SOAPMessageContext context)
  {
      // for a large message, this will cause an OutOfMemoryError
      System.out.println( context.getMessage().countAttachments() );
  ...
  </code></pre>
  
  <p>My question is: is there a known mechanism/workaround for dealing with this? Specifically, it would be nice to access the SOAP part in a SOAP message without forcing the attachments (if MTOM for example) to also be vacuumed up.</p>