JAX-WS, MTOM and temporary files
I need to send a temporary file via a webservice. I set it up to use MTOM and set a DataSource on the relevant element. Problem is, how can I reliably find out that JAX-WS is done with using the DataSource so I can delete the file? I tried a custom DataSource which calls delete on the file when close() is called on the InputStream it returns but that doesn't work as JAX-WS seems to call the getInputStream() method more than once (probably because I do some logging and/or have outgoing request validation enabled). Any way, that seems more like a hack in the first place. So, what is the correct method to find out that JAX-WS is done with a particular request/response so resources the application has allocated for it can be released?