----- Original Message -----
Sent: Wednesday, July 17, 2002 11:48
PM
Subject: Re: transfer of compressed
data
I am not sure if ur trying to send the files as a
soap attachment...
Here is the peice of code i used to send
files as SOAP attachement..it works for a zip file too.
File f = new
File(pathname);
//Create a FileDataSource with the uploaded
file
FileDataSource
FDS=new FileDataSource(f);
//
Create the Attachment part using the FileDataSource
AttachmentPart ap = message.createAttachmentPart(new
DataHandler(FDS));
//Set
the Content Type of the file as that of the attachment
part
ap.setContentType(type);
// Add the
attachment part to the message.
message.addAttachmentPart(ap);
message.saveChanges();
And then send this message as
usual...
on the recieving end...
here ap is the attachment part of the soap
message...
if(ap.getContentType().equals("text/plain"))
{
String
wsContent=(String)ap.getContent();
data="wsContent.getBytes();
}
else
{
InputStream is =(InputStream)ap.getContent();;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream
();
byte buf[] = new
byte[4096];
int length;
while
(true)
{
length = is.read
(buf);
if (length <
0)
{
break;
}
outputStream.write (buf, 0,
length);
}
data =
"outputStream.toByteArray" ();
}
File outFile =new
File(pathName);
FileOutputStream FOS=new
FileOutputStream(outFile);
FOS.write(data);