使用 Apache CXF 传输大消息
我正在编写 CXF WS 来上传一些大文件 - 最多 1GB。在大多数情况下,它们不会> 10-15MB,但问题是加载文件并使用标准绑定将其作为常规 byte[] 发送是无效的。因此,可能需要自定义拦截器,但我不确定它是唯一的选择以及如何编写它。
I'm writing a CXF WS to upload some large files - up to 1GB. In most cases they won't be >10-15MB, but the problem is that it is ineffective to load the file and send it as regular byte[] using the standard binding. For that reason a custom interceptor might be needed but I'm not sure it is the only option as well as how to write it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CXF 支持 MTOM 规范,并为二进制数据提供更高效的传输编码,而且还为使用 JAXB 绑定提供了更灵活的 API。这将二进制数据与
byte[]
解耦,并将其替换为DataHandler
,它允许您从流而不是byte[].这适用于连接的客户端和服务器端。
CXF supports the MTOM specification, which as well as providing a more transmission-efficient encoding for binary data, but also provides a more flexible API for binding using JAXB. This decouples the binary data from
byte[]
and replaced it with aDataHandler
, which allows you to source the data from streams, rather thanbyte[]
. This applies both to client and server ends of the connection.