[Axis2] MTOM binary content
Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele
Re: [Axis2] MTOM binary content
Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu
Re: [Axis2] MTOM binary content
Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my;, my); OMElement data = fac.createOMElement(mtomSample, omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); //data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() .getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu
RE: [Axis2] MTOM binary content
XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inputFile)); OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), parser); OMElement xmlDocElement = builder.getDocumentElement(); This assumes that inputFile is a java.io.File. This code can be found at: http://ws.apache..org/axis2/0_95/OMTutorial.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 6:36 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my, my); OMElement data = "" omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); // data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() ..getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu This e-mail and any files transmitted with it are intended solely for the use of the entity or individual(s) to whom they are addressed and not for reliance upon by unintended recipients. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail and any files transmitted are strictly prohibited. If you have received this e-mail in error please delete the entire email and immediately notify us by email to the sender or by telephone to the AOC main office number, (404) 656-5171. Thank you.
Re: [Axis2] MTOM binary content
Hi Micheal, thanks for your reply. Is your solution MTOM compliant? Michael Robinson wrote: XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inputFile)); OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), parser); OMElement xmlDocElement = builder.getDocumentElement(); This assumes that “inputFile” is a java.io.File. This code can be found at: *MailScanner has detected a possible fraud attempt from ws.apache.org claiming to be* http://ws.apache..org/axis2/0_95/OMTutorial.html http://ws.apache.org/axis2/0_95/OMTutorial.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 6:36 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my;, my); OMElement data = fac.createOMElement(mtomSample, omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); //data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() ..getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu * This e-mail and any files transmitted with it are intended solely for the use of the entity or individual(s) to whom they are addressed and not for reliance upon by unintended recipients. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail and any files transmitted are strictly prohibited. If you have received this e-mail in error please delete the entire email and immediately notify us by email to the sender or by telephone to the AOC main office number, (404) 656-5171. Thank you. *
RE: [Axis2] MTOM binary content
My solution only loads binary content into an OMElement (not really my solution... just copied and pasted from the online docs). For MTOM compliance see http://ws.apache.org/axis2/0_95/mtom-guide.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 7:38 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Micheal, thanks for your reply. Is your solution MTOM compliant? Michael Robinson wrote: XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inputFile)); OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory() , parser); OMElement xmlDocElement = builder.getDocumentElement(); This assumes that inputFile is a java.io.File. This code can be found at: *MailScanner has detected a possible fraud attempt from ws.apache.org claiming to be* http://ws.apache..org/axis2/0_95/OMTutorial.html http://ws.apache.org/axis2/0_95/OMTutorial.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 6:36 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my;, my); OMElement data = fac.createOMElement(mtomSample, omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); //data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() ..getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu * This e-mail and any files transmitted with it are intended solely for the use of the entity or individual(s) to whom they are addressed and not for reliance upon by unintended recipients. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail and any files transmitted are strictly prohibited. If you have received this e-mail in error please delete the entire email and immediately notify us by email to the sender or by telephone to the AOC main office number, (404) 656-5171. Thank you. *
Re: [Axis2] MTOM binary content
Hi, What is required for the DataHandler is some sort of input soure. So as long as you have a DataSource that represents the binary then you are fine! Here is a code sample for doing that previous code FileDataSource dataSource = new FileDataSource(yourfile.zip); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); This should create a proper Datahandler for the OMText to attach the file Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my;, my); OMElement data = fac.createOMElement(mtomSample, omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); //data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() .getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu -- Ajith Ranabahu
Re: [Axis2] MTOM binary content
Micheal, my question comes from there, since the sample shown at http://ws.apache.org/axis2/0_95/mtom-guide.html loads and sends jpg files using the org.apache.axis2.attachments.utils classes, while it seems there's nothing similar to handle other formats. Michele Michael Robinson wrote: My solution only loads binary content into an OMElement (not really my solution... just copied and pasted from the online docs). For MTOM compliance see http://ws.apache.org/axis2/0_95/mtom-guide.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 7:38 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Micheal, thanks for your reply. Is your solution MTOM compliant? Michael Robinson wrote: XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inputFile)); OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory() , parser); OMElement xmlDocElement = builder.getDocumentElement(); This assumes that inputFile is a java.io.File. This code can be found at: *MailScanner has detected a possible fraud attempt from ws.apache.org claiming to be* http://ws.apache..org/axis2/0_95/OMTutorial.html http://ws.apache.org/axis2/0_95/OMTutorial.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 6:36 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my;, my); OMElement data = fac.createOMElement(mtomSample, omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); //data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() ..getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu * This e-mail and any files transmitted with it are intended solely for the use of the entity or individual(s) to whom they are addressed and not for reliance upon by unintended recipients. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail and any files transmitted are strictly prohibited. If you have received this e-mail in error please delete the entire email and immediately notify us by email to the sender or by telephone to the AOC main office number, (404) 656-5171. Thank you. *
RE: [Axis2] MTOM binary content
Instead of the ImageDataSource used in the online example try it with the ByteArrayDataSource to load your binary content. There is a constructor that takes a byte[] that works very nicely. API docs for this class are at: http://ws.apache.org/commons/axiom/apidocs/index.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 9:35 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Micheal, my question comes from there, since the sample shown at http://ws.apache.org/axis2/0_95/mtom-guide.html loads and sends jpg files using the org.apache.axis2.attachments.utils classes, while it seems there's nothing similar to handle other formats. Michele Michael Robinson wrote: My solution only loads binary content into an OMElement (not really my solution... just copied and pasted from the online docs). For MTOM compliance see http://ws.apache.org/axis2/0_95/mtom-guide.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 7:38 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Micheal, thanks for your reply. Is your solution MTOM compliant? Michael Robinson wrote: XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inputFile)); OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory() , parser); OMElement xmlDocElement = builder.getDocumentElement(); This assumes that inputFile is a java.io.File. This code can be found at: *MailScanner has detected a possible fraud attempt from ws.apache.org claiming to be* http://ws.apache..org/axis2/0_95/OMTutorial.html http://ws.apache.org/axis2/0_95/OMTutorial.html -Original Message- From: Michele Mazzucco [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 6:36 AM To: axis-user@ws.apache.org Subject: Re: [Axis2] MTOM binary content Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(http://localhost/my;, my); OMElement data = fac.createOMElement(mtomSample, omNs); OMElement image = fac.createOMElement(image, omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource(test.jpg, expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement(fileName, omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement(wrap,omNs); //data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage(image/jpeg, actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() ..getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: Hi, As far as the content is concerned the zip file is a binary file just like the image file. All you have to do is read the file through a file input stream and then create a new DataSource using that inputstream. Ajith On 5/4/06, Michele Mazzucco [EMAIL PROTECTED] wrote: Hi all, the tutorial show how to send images with MTOM, but how can I send binary files with MTOM (say .zip files)? Thanks in advance, Michele -- Ajith Ranabahu * This e-mail and any files transmitted with it are intended solely for the use of the entity or individual(s) to whom they are addressed and not for reliance upon by unintended recipients. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail and any files transmitted are strictly prohibited. If you have received this e-mail