JAX-WS MTOM 发送到客户端后删除附件

发布于 2024-10-04 11:51:02 字数 454 浏览 0 评论 0原文

我正在使用 Java 1.6 的 JAX-WS 参考实现。在我的服务器上,我有 Web 服务方法,它返回带有附件的响应作为 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

我需要做的是将文件从服务器完全发送到客户端后删除。然而,我的网络服务方法在客户端发送响应之前就已经完成了。

我可以做什么来将文件标记为删除,或者是否有一个回调可以挂钩以在传输后删除文件?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的痛♀有谁懂 2024-10-11 11:51:02

这个问题有一些答案

There are some answers to this question here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文