Title: Message
 
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: Dan Allen
Sent: Tuesday, July 16, 2002 8:36 PM
Subject: RE: transfer of compressed data

 Why? SOAP with attachments handles binary data directly does it not?  Apache SOAP uses
application/octet-stream for attachments.
 
Dan
-----Original Message-----
From: William Brogden [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 16, 2002 11:00 AM
To: [EMAIL PROTECTED]
Subject: RE: transfer of compressed data

-----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

Hi All,
I am able to transfer xml files to SOAP server from Client using DataHandler.But I am facing problem in transferring compressed data such as zip archives using the same concept.
 Can anybody tell me how to transfer zip files from SOAP client to server side?
 
Thanks,
Niket  
 
Zipped data will have to be transmitted as base64Binary
 

[EMAIL PROTECTED]
Author of Soap Programming with Java - Sybex; ISBN: 0782129285

Reply via email to