I am using the reference implementation of JAX-WS with Java 1.6. On my server I have Web Service method which returns a response with an attachment as a javax.activation.DataHandler.
File myFile = new File("tempFile.txt"); //existing temp file to send back
DataHandler dh = new DataHandler(new FileDataSource(myFile));
//cant delete myFile yet, but end of web service method
What I need to do is delete the file after it has been completely sent from the server to the client. However my webservice method has finished before the response is sent from the client.
What can I do to mark the file for deletion, or is there a callback I can hook into to delete the file after transmission?
thanks
There are some answers to this question here.