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 Peter <zc...@gmx.net> on 2007/01/04 14:32:10 UTC
[axis 1.4] dime attachments
hi list,
i would like to handle multiple dime attachments in one request.
a request can transport more then one attachment.
each attachment can be large up to 4 MB.
when i send small attachments I only got the problem that the
isReadyToGetNextStream() is always true.
when I send a request with 3 attachments.
attachment 1: size of 10kB
attachment 2: size of 3.5MB
attachment 3: size of 6kB
I got the following exception:
IOException: End of physical stream detected when 36 more bytes expected.
when processing attachment 3
here comes my code.
if (inputAttachmentType == Attachments.SEND_TYPE_DIME){
Attachments att = reqMsg.getAttachmentsImpl();
IncomingAttachmentStreams incoming = att.getIncomingAttachmentStreams();
try {
int i = 0;
while (incoming.isReadyToGetNextStream()){
IncomingAttachmentInputStream attachmentInputStream = incoming.getNextStream();
DataSource ds = new ByteArrayDataSource(attachmentInputStream,null);
DataHandler dh = new DataHandler(ds);
InputStream in = dh.getInputStream();
/**
* max size 4MB
*/
checkAttSize(in.available());
/**
* get attachment data
*/
FileOutputStream file = new FileOutputStream(attfiles.get(i),false);
byte[] buffer = new byte[in.available()];
int bytes_read;
while ((bytes_read = in.read(buffer)) != -1) {
file.write(buffer, 0, bytes_read);
}
file.close();
in.close();
i++;
}
} catch (Exception e) {
ExceptionHandel.exhandel("extractAtt", e, null);
}
}
thanks, peter
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org