You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Alan Aguia <aa...@yahoo.com> on 2005/12/15 17:19:31 UTC

RE: Newbie: Recreating Zip file in MTOM service class

      I couldnt do it. I dont get it. Can you show me your code. I cant get the zip file again
   
  Thanks
  Alan.
   
  ---------------------------------------------------------------
   
  How about

java.util.zip.ZipInputStream(actualDH.getInputStream());

Best regards,
Guenter


> -----Original Message-----
> From: Antony Grinyer [mailto:antony.grinyer@csw.co.uk] 
> Sent: Wednesday, October 12, 2005 6:42 PM
> To: axis-user@ws.apache.org
> Subject: Newbie: Recreating Zip file in MTOM service class?
> 
> Hi,
> 
> Being an axis2 newbie, I've managed to create an MTOM client and
> service, passing a Zip file to the service, however I'm unsure what to
> do at the service end to recreate the zip? The example on the axis2
> website just shows what to do with an image. Here's snippets 
> of my code:
> 
> CLIENT:
> 
> << snip >>
> 
> OMElement zip = fac.createOMElement("zip", omNs);
>  
> File file = new File(filePath);
> 
> byte[] bytes = new byte[(int)file.length()];
> bytes = BDBXMLUtils.getBytesFromFile(file);
> ByteArrayDataSource dataSource = new ByteArrayDataSource(bytes);
> dataHandler = new DataHandler(dataSource);
> OMText textData = fac.createText(dataHandler, true);
> zip.addChild(textData);
> 
> << snip >>
> 
> The do all the client calls to the addDocumentsAsZip web 
> service method.
> 
> SERVICE:
> 
> public OMElement addDocumentsAsZip(OMElement element)
>     throws XMLStreamException
>   {
>     OMFactory fac = OMAbstractFactory.getOMFactory();
>     OMNamespace omNs =
> fac.createOMNamespace("http://some.namespace/anything", "anything");
> 
>     OMElement zipEle = element.getFirstElement();
>     OMElement zipName = (OMElement) zipEle.getNextSibling();
>     OMText binaryNode = (OMText) zipEle.getFirstChild();
>     String fileName = zipName.getText();
> 
>     DataHandler actualDH = (DataHandler)binaryNode.getDataHandler(); 
> 
>     // Now, how do I get the data back into a zip?
> 
> << snip >>
> 
> I know there's the Java util.zip package but how do I recreate my zip
> from the DataHandler?
> 
> Any help gratefully appreciated.
> Thanks,
> Antony
> 
> 
> 





			
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping