Hi!

We have published a soap endpoint using cxf 2.7.10 on tomcat 6 and jdk 6.
The web service request may contain one or more attachments (mtom support is
enabled).
The server side classes that we have we implemented to manage the request
need to read the stream of every attachment more than one time. 

In most of our tests we have used files whose size was < 100KB and we had
not found problems. Than, using a file with greater size, we have discovered
that the subsequents calls to get the attachments stream receive an empty
stream if the previous stream consumer has (correctly) closed it.

This behaviour is described here (an old post):

http://ext2xhb.wordpress.com/2011/06/08/using-cxf-attachment-safely/

at point 1 and in particular in the statement: "closing stream of attachment
“cached with temporary file”  will delete temporary file, and replace it’s
content with a empty byte array."

In that blog they suggest to use the cxf api to hold the attachment. Is it
the best way to manage my requirement to read the stream of an attachment
more times? Could a custom interceptor that manages the unhold task help me
to let the code clean from this logic?

IMHO the different behavior between the case where the file is bigger or
smaller than 100 kb is a little bit confusing and dangerous if unknown. In
fact if we had not noticed this behavior we would have risked to lose the
content of the file without a check on file size greater than zero. Why not
to launch an Exception if the stream is unexpectedly unavailable when it is
requested again?  

Thank you very much for the great work with cxf! 
Stefano






--
View this message in context: 
http://cxf.547215.n5.nabble.com/Empty-stream-when-reading-twice-the-content-of-an-attachment-greater-than-100KB-tp5745031.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to