---------- Forwarded message ---------- From: Sushil Dodake <[EMAIL PROTECTED]> Date: Sep 4, 2007 6:49 PM Subject: AXIS2 : Help required : getting a zip file using AXIS2 + AXIOM To: axis-dev@ws.apache.org
---------- Forwarded message ---------- From: Sushil Dodake <[EMAIL PROTECTED]> Date: Sep 4, 2007 6:47 PM Subject: Re: Help required : getting a zip file using AXIS2 + AXIOM To: Thilina Gunarathne <[EMAIL PROTECTED]> Hi, Thanks you very much for a very prompt reply.. I have also sent this mail to the group you told me. As i need to fix this issue ASAP i am also sending this presonally. The code snippet on the server side is as below. ** *Breife description --> * *1. Take the JPEG files data in byte array format from the Documentum server and store it in a List * *2. Generate a Zip file and store it on the HDD* *3. get the zip file as input stream, Convert it in to binary array* *4. send it using a data handler.* *private* OMElement createZipData(List ObjectList) *throws* ContentFault{ ZipOutputStream ZipOutStream; OMFactory factory = OMAbstractFactory.*getOMFactory*(); OMNamespace payloadNs= factory.createOMNamespace( *XML_NAMESPACE*, *XML_NAMESPACE_PREFIX* ); OMElement zipContent = factory.createOMElement( "ZipContent", payloadNs); *try* { String zipPath = *this*.zipFilePath; Date currentDate = *new* Date(); *long* time = currentDate.getTime(); //Create a local Zip File to add all the Images (binary data) zipPath = zipPath + "\\file"+ String.*valueOf*(time)+ ".zip" ; System. *out*.println("Zip Path " + zipPath); ZipOutStream = *new* ZipOutputStream(*new* FileOutputStream(zipPath)); *int* totalObjects = ObjectList.size(); *for*(*int* i = 0; i < totalObjects; i++){ DCTMObject nextObject = (DCTMObject)ObjectList.get(i); List contentList = nextObject.getContentList(); *if*(contentList != *null*){ *int* contentListSize = contentList.size(); *for*(*int* j = 0; j < contentListSize; j++){ //Get the binary content of the image data ObjectContent content = (ObjectContent)contentList.get(j); *if*(content != *null*){ *byte* []byteContent = content.getContent(); ZipEntry fileName = *new* ZipEntry(content.getName()); ZipOutStream.putNextEntry(fileName); *byte* []tempArray = *new* *byte *[4096]; *int* flag; BufferedInputStream bi = *new* BufferedInputStream(*new* ByteArrayInputStream(byteContent)); *while* ((flag = bi.read(tempArray, 0, 4096)) != -1) { ZipOutStream.write(tempArray, 0, flag); } ZipOutStream.closeEntry(); } } } } //Local Zip File created ZipOutStream.close(); //Read the zip Loacl zip file and convert it in the byte array ZipInputStream zipInStream = *new* ZipInputStream(*new* BufferedInputStream( *new*FileInputStream(zipPath))); *byte* [] zipByte = *new* *byte *[zipInStream.available()]; System. *out*.println("Getting Zipped Data Total Size =" + zipInStream.available()); zipInStream.read(zipByte, 0, zipInStream.available()); ByteArrayDataSource byteData = *new* ByteArrayDataSource(zipByte); //Use a data handler to send the binary data (byte array) DataHandler handler = *new* DataHandler(byteData); OMText fileData = factory.createOMText(handler, *true*); zipContent.addChild(fileData); //objContent.addChild(fileContent); } *catch* (IOException e) { System. *out*.println("In the createZipData Catch"); e.printStackTrace(); *throw* *new* ContentFault("In the createZipData Catch" ); } System. *out*.println("Response Zip Conmtent" + zipContent.toString ()); *return* zipContent; } On 9/4/07, Thilina Gunarathne <[EMAIL PROTECTED] > wrote: > > Hi, > > <tns:ZipContent>AA==</tns:ZipContent> > > > What you have got above is the base64 representation of the data you > have attached in your server side. There is a possibility that data is > not correctly attached in the server side. > > Are you using any data binding mechanisms. If so what... Also post me > the WSDL if it's possible.. > > I also would like to see how you are attaching the data at the server > side.. > > Also you can post your Axis2 related questions to axis-user list > ( http://ws.apache.org/axis2/mail-lists.html ) with [Axis2] prefix in > the subject. In there you'll find more people to answer your questions > and more people will benefit from the answers you are getting.. FYI: I > frequently checks that list.. > > thanks, > Thilina > > On 9/4/07, Sushil Dodake <[EMAIL PROTECTED] > wrote: > > Hi Thilina, > > I got your mail address from the link. > > > http://archives.devshed.com/forums/apache-92/axis2-contentid-is-null-using-mtom-1880965.html > > i have a problem in sending a zip file using AXIS2 + AXIOM > > when i send a zip file then @ the client side i get > > > > > > <tns:ZipedObjects > > xmlns:tns="http://content.dctm.service.toro.com "> > > > > <tns:ZipContent>AA==</tns:ZipContent> > > > > </tns:ZipedObjects> > > > > but the actual zip file conteains 2 jpeg images... > > > > i have absolutely no idea as in how to retrieve the jpeg files from the > > received presentation of the zip file. > > > > i tried using the folowing snippet to retrieve the data > > > > > > > > OMElement zipFile = result.getFirstChildWithName(new QName("ZipContent" > )); > > > > OMText zipData = (OMText)( result.getFirstElement()).getFirstOMChild(); > > > > zipData.setOptimize(true); > > > > DataHandler dataHand = > > (DataHandler)zipData.getDataHandler(); > > > > FileOutputStream dest = new FileOutputStream("c:\\sushilData.zip" ); > > > > ZipOutputStream out = new ZipOutputStream(new > BufferedOutputStream(dest)); > > > > dataHand.writeTo(dest); > > > > dest.flush(); > > > > dest.close(); > > > > out.close(); > > > > > > > > but it gices me error saying the zip file should have atleast on entry. > > > > Please guid me in this regard. > > > > My requirement is i need to get the JPEG files from a documentum server > and > > then zip them in a zip file and send it over to the client. > > > > Regards, > > > > Sushil > > > -- > Thilina Gunarathne - http://www.wso2.com - http://thilinag.blogspot.com >