I have tried to run samples/mime code where I
am sending zip file form SOAP client.
I have made changes in
MimeTestClient.java
earlier
if (args[1].equals("sendFile") || args[1].equals("loopFile")) for (int i = 2; i < args.length; i++) { DataSource ds = new ByteArrayDataSource(new File(args[i]), null); DataHandler dh = new DataHandler(ds); params.addElement(new Parameter("addedfile", javax.activation.DataHandler.class, dh, null)); } Modified(for sending zip file
if (args[1].equals("sendFile") || args[1].equals("loopFile")) for (int i = 2; i < args.length; i++) { File file = new File("F:/soap-2_3_1/samples/mime/data.zip"); FileInputStream fis = new
FileInputStream(file);
ZipInputStream in = new ZipInputStream(new BufferedInputStream(fis));
DataSource ds = new
ByteArrayDataSource(in,"application/octet-stream");
DataHandler dh = new DataHandler(ds); params.addElement(new Parameter("addedfile", javax.activation.DataHandler.class, dh, null)); } On server side MimeTest.java
I have modified as
public static String sendFile(DataHandler dh) throws IOException
{
StringBuffer sb = new StringBuffer("Received attachment:\n"); try{ sb.append("Content type:
").append(dh.getContentType());
sb.append("\nName: ").append(dh.getName()); Object o = dh.getContent(); sb.append("\nContent class: ").append(o.getClass().getName()); sb.append("\nContent: ").append(o.toString()); String name="F:/soap-2_3_1/samples/mime/server/data.zip"; InputStream is=dh.getInputStream(); ZipInputStream zs= new
ZipInputStream(is);
doUnzip(name,zs);
}catch(Exception
e){e.printStackTrace();}
return sb.toString(); } public static void doUnzip(String fileName,ZipInputStream in) throws Exception{ try { //FileInputStream fis = new
FileInputStream(fileName);
//ZipInputStream in = new ZipInputStream(new BufferedInputStream(fis)); ZipEntry ze; while((ze = in.getNextEntry()) != null)
{
System.out.println("Extracting file " + ze); String fileName1=ze.getName(); OutputStream out = new FileOutputStream("F:/soap-2_3_1/samples/mime/server/"+fileName1.substring(fileName1.lastIndexOf("/"))); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // Close the
streams
out.close(); /*int x;
while((x = in.read()) != -1) System.out.write(x);*/ } in.close(); } catch(Exception e) { e.printStackTrace(); } }
-----Original Message-----
From: Niket Anand [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 16, 2002 9:18 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: transfer of compressed data
|
Title: Message
- transfer of compressed data Niket Anand
- transfer of compressed data Niket Anand
- Re: transfer of compressed data Niket Anand
- Re: transfer of compressed data Andrew Yang
- transfer of compressed data Niket Anand
- Re: transfer of compressed data Ramya Virudhs
- Re: transfer of compressed data Niket Anand
- Re: transfer of compressed data Niket Anand