7 Replies Latest reply on Nov 28, 2007 7:25 AM by Oskar Carlstedt

    Dynamic no. of attachments using MTOM

    Oskar Carlstedt Novice

      Hi!

      Has anyone made i possible to implement a web service that can receive or send multiple attachments using MTOM. All examples just have one DataHandler but this is not enough for what I want to do. I want to be able to use a dynamic number of attachments.

      XOP has support for several attachments in the xml document but how does JBoss and especially Java EE treat such a data structure. Where can I find my attachments?

      If I use the Provider< SOAPMessage > mechanism I have full control, but still the question: Where can I find the send attachments? Do I have to use a Provider< Source > implementation to solve this?

      My web service consumers want to send multiple documents to our server in one request. Upon other requests, I will generate a dynamic number of PDF documents on the server and then send them to the client. Is it possible? Of course we can bundle all attachments into a zip file and get one attachment - but this is an ugly work around.

      I hope someone can answer this question.

      Regards
      /Oskar

        • 1. Re: Dynamic no. of attachments using MTOM
          Richard Opalka Master

          Hi,

          did you try to use List or DataHandler[] data object as your method argument? It should work as well.

          Richard

          • 2. Re: Dynamic no. of attachments using MTOM
            Oskar Carlstedt Novice

            Hi! Thanks for a quick reply!

            Ok! It might be a good one to do so. When using a DataHandler list , where do I get the rest of my xml document. If using document/literal I will post/receive an xml document that may contain other textual information. In other words, my xml may contain some "normal" xml information and some binary information.

            Regards
            /Oskar

            • 3. Re: Dynamic no. of attachments using MTOM
              Richard Opalka Master

               

              "oskar.carlstedt" wrote:

              When using a DataHandler list , where do I get the rest of my xml document. If using document/literal I will post/receive an xml document that may contain other textual information.


              I don't understand this question :-(

              "oskar.carlstedt" wrote:

              In other words, my xml may contain some "normal" xml information and some binary information.


              This shouldn't be the problem. MTOM should work in such scenarios as well.

              Richard

              • 4. Re: Dynamic no. of attachments using MTOM
                Oskar Carlstedt Novice

                Ok!

                What I mean is when I have a DataHandler I can get an input stream to the reach the attachment data. But what if I have the following xml. How do I get my xml document:

                <my-xml>
                 <list-of-something>
                 <something>
                 <normal-xml>
                 <textual-info-1> SOME TEXTUAL INFO 1 </textual-info-1>
                 <textual-info-2> SOME TEXTUAL INFO 2 </textual-info-2>
                 </normal-xml>
                 <binary>this part will go as MTOM attachment</binary>
                 <something>
                 <something>
                 <normal-xml>
                 <textual-info-1> SOME TEXTUAL INFO 1 </textual-info-1>
                 <textual-info-2> SOME TEXTUAL INFO 2 </textual-info-2>
                 </normal-xml>
                 <binary>this part will go as MTOM attachment</binary>
                 <something>
                 </list-of-something>
                </my-xml>
                


                Are there two methods that are invoked in the implementing code. As I understand the DataHandler will give me the InputStream to the attachment (binary in above xml). But there is no way to get the rest of the xml, or is it?

                Regards
                /Oskar


                • 5. Re: Dynamic no. of attachments using MTOM
                  Oskar Carlstedt Novice

                  Hi again!

                  Is this as simple as just creating JAX-B objects having normal annotations and then let one of the child objects take a DataHandler as argument?

                  One more question. Where do all the attachments go if I use the Provider< SOAPMessage > implementation?

                  Regards
                  /Oskar

                  • 6. Re: Dynamic no. of attachments using MTOM
                    Richard Opalka Master

                     

                    "oskar.carlstedt" wrote:
                    Ok!

                    What I mean is when I have a DataHandler I can get an input stream to the reach the attachment data. But what if I have the following xml. How do I get my xml document:

                    <my-xml>
                     <list-of-something>
                     <something>
                     <normal-xml>
                     <textual-info-1> SOME TEXTUAL INFO 1 </textual-info-1>
                     <textual-info-2> SOME TEXTUAL INFO 2 </textual-info-2>
                     </normal-xml>
                     <binary>this part will go as MTOM attachment</binary>
                     <something>
                     <something>
                     <normal-xml>
                     <textual-info-1> SOME TEXTUAL INFO 1 </textual-info-1>
                     <textual-info-2> SOME TEXTUAL INFO 2 </textual-info-2>
                     </normal-xml>
                     <binary>this part will go as MTOM attachment</binary>
                     <something>
                     </list-of-something>
                    </my-xml>
                    


                    Are there two methods that are invoked in the implementing code. As I understand the DataHandler will give me the InputStream to the attachment (binary in above xml). But there is no way to get the rest of the xml, or is it?

                    Regards
                    /Oskar


                    This shouldn't be the problem for you. The jbossws tools should generate something like this from WSDL document for you:

                    public void method(List<Something> data)
                    {
                    ...
                    }
                    
                    public class Something
                    {
                     NormalXml normalXml
                     DataHandler binary
                    }


                    Richard