jax-ws
  1. jax-ws
  2. JAX_WS-971

MTOM disabled when using SOAPHandler

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: 2.2.7
    • Component/s: handlers
    • Labels:
      None

      Description

      Using MTOM to stream large files with @XmlMimeType("application/octet-stream") is working well but when using a SOAPHandler to add some extra informations in the SOAP header, for example, all the xop attachments are "reintegrated" in the soap document as base 64 encoded values. This make OutOfMemoryException with larges files and is not acceptable. By using CXF implementation, this working well !

      I do not want to use specific things like tubes, as it is not standard.

        Issue Links

          Activity

          Hide
          yblazart76 added a comment -

          First, I discover myself that we need to use @XmlAttachmentRef with @XmlMimeType. This keep the document as a SAAJ attachment.

          But there is always a OOM exception. This is because SAAJAttachment load the document in memory before write it in the OutputStream when the codec's ask it.

          In com.sun.xml.ws.message.saaj.SAAJMessage class we have @ line 524 :

          private class SAAJAttachment implements Attachment

          In this inner class with have the following method :

          /**

          • Writes the contents of the attachment into the given stream.
            */
            public void writeTo(OutputStream os) throws IOException { os.write(asByteArray()); }

          The method asByteArray() return a byte[] of course. As you can see, everything is loaded in memory.

          The wethod writeTo() is called the the Mime and MTOM codecs.

          Show
          yblazart76 added a comment - First, I discover myself that we need to use @XmlAttachmentRef with @XmlMimeType. This keep the document as a SAAJ attachment. But there is always a OOM exception. This is because SAAJAttachment load the document in memory before write it in the OutputStream when the codec's ask it. In com.sun.xml.ws.message.saaj.SAAJMessage class we have @ line 524 : private class SAAJAttachment implements Attachment In this inner class with have the following method : /** Writes the contents of the attachment into the given stream. */ public void writeTo(OutputStream os) throws IOException { os.write(asByteArray()); } The method asByteArray() return a byte[] of course. As you can see, everything is loaded in memory. The wethod writeTo() is called the the Mime and MTOM codecs.
          Hide
          Martin Grebac added a comment -

          Even though the method itself you point out can be optimized for memory, please be aware of the fact that MTOM is only an optimization for the on-the-wire encoding. It doesn't necessarily mean that MTOM feature itself automatically allows you to transfer large payloads - especially not in case of handlers which are DOM based.
          For additional information also please read:
          http://weblogs.java.net/blog/kumarjayanti/archive/2009/12/10/summary-proprietary-features-saaj-ri-134?force=204

          Show
          Martin Grebac added a comment - Even though the method itself you point out can be optimized for memory, please be aware of the fact that MTOM is only an optimization for the on-the-wire encoding. It doesn't necessarily mean that MTOM feature itself automatically allows you to transfer large payloads - especially not in case of handlers which are DOM based. For additional information also please read: http://weblogs.java.net/blog/kumarjayanti/archive/2009/12/10/summary-proprietary-features-saaj-ri-134?force=204

            People

            • Assignee:
              miroslav.kos
              Reporter:
              yblazart76
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: