[ http://issues.apache.org/jira/browse/AXIS-2084?page=all ]
Brian Husted updated AXIS-2084:
-------------------------------
Attachment: DimeBodyPart.java
Dims,
After exhaustive debugging, I have attached a patch to fix this issue. The
problem was related to the TYPE and ID header lengths/data being sent on EVERY
DIME chunk. Per the DIME specification section 2.1.3 the ID_LENGTH and
TYPE_LENGTH and associated data shall only be sent in the FIRST chunk (please
see http://www.gotdotnet.com/team/xml_wsspecs/dime/draft-nielsen-dime-01.txt).
It appears from the code comments an attempt was made to satisfy this
requirement but failed to execute properly leading to the errors we have been
seeing. The patch was tested both with attachments that were larger in size
than the chunk size and greater in size. In addition, testing was performed
attaching both single and multiple attachments in the SOAP message.
The changes that were made included adding two new static variables, modified
sendHeader and send(java.io.OutputStream os, byte position,
DynamicContentDataHandler dh,
final long maxchunk) methods. The send method was modified to pass
in a value of CHUNK for the first DIME chunk and CHUNK_NEXT for subsequent
chunks. Then in the sendHeader method, the logic for detecting the first chunk
was modified to check if the value is CHUNK then send the ID and TYPE.
Subsequent chunks are then sent without the ID and TYPE.
In addition, the code sending the last chunk was modified to detect if the last
chunk was also the first chunk. This arises when the chunk size is larger than
the attachment size. In this case, where only one chunk is being sent I pass
in ONLY_CHUNK flag. The sendHeader then handles this by NOT setting the CF
flag and sending the ID and TYPE.
The code still needs to be tested with a .NET server. Our WS partners will be
testing with this code in the next two weeks but it would be great if someone
could test ahead of that.
-- Brian
> Dime attachements: Type_Length of the final record chunk must be zero
> ---------------------------------------------------------------------
>
> Key: AXIS-2084
> URL: http://issues.apache.org/jira/browse/AXIS-2084
> Project: Apache Axis
> Type: Bug
> Components: Serialization/Deserialization
> Versions: 1.2, 1.2.1
> Environment: Microsoft XP
> Reporter: Coralia Silvana Popa
> Assignee: Davanum Srinivas
> Attachments: DimeBodyPart.java, DimeBodyPartDiff.txt, EchoAttachment.java
>
> Large files sent as DIME attachments are not correct serialized. Seems that
> the
> When reading a series of chunked records, the parser assumes that the first
> record without the CF flag is the final record in the chunk; in this case,
> it's the last record in my sample. The record type is specified only in the
> first record chunk, and all remaining chunks must have the TYPE_T field and
> all remaining header fields (except for the DATA_LENGTH field) set to zero.
> Seems that Type_Length (and maybe other header fields) is not set to 0 for
> the last chunk. The code work correct when there is only one chunck.
> The problem is in class: org.apache.axis.attachments.DimeBodyPart, in method
> void send(java.io.OutputStream os, byte position, DynamicContentDataHandler
> dh, final long maxchunk)
> I suggest the following code the fix this problem:
> void send(java.io.OutputStream os, byte position, DynamicContentDataHandler
> dh,
> final long maxchunk)
> throws java.io.IOException {
>
> BufferedInputStream in = new
> BufferedInputStream(dh.getInputStream());
>
> final int myChunkSize = dh.getChunkSize();
>
> byte[] buffer1 = new byte[myChunkSize];
> byte[] buffer2 = new byte[myChunkSize];
>
> int bytesRead1 = 0 , bytesRead2 = 0;
> bytesRead1 = in.read(buffer1);
>
> if(bytesRead1 < 0) {
> sendHeader(os, position, 0, (byte) 0);
> os.write(pad, 0, dimePadding(0));
> return;
> }
> byte chunknext = 0;
> do {
> bytesRead2 = in.read(buffer2);
>
> if(bytesRead2 < 0) {
> //last record...do not set the chunk bit.
> //buffer1 contains the last chunked record!
> sendChunk(os, position, buffer1, 0, bytesRead1,
> chunknext);
> break;
> }
>
> sendChunk(os, position, buffer1, 0, bytesRead1,(byte)
> (CHUNK | chunknext) );
> chunknext = CHUNK_NEXT;
> //now that we have written out buffer1, copy buffer2
> into to buffer1
> System.arraycopy(buffer2,0,buffer1,0,myChunkSize);
> bytesRead1 = bytesRead2;
>
> }while(bytesRead2 > 0);
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira