休息+ xop / 嵌入在 xml 响应中的二进制数据

发布于 2024-10-07 12:37:31 字数 485 浏览 0 评论 0原文

我的任务是将二进制数据(如图片、音乐、缩略图等)嵌入到 xml 元数据容器中,以便通过 REST 接口发布整个包。目前我们在项目中使用 Jersey 和 spring。 我真的不想退回到soap/wsdl(这似乎是每个基于ws的问题的默认答案)或任何容器格式(如zip)只是为了通过网络获取数据,所以我用谷歌搜索了一段时间以了解更多信息适当的解决方案。

我发现建议使用 XOP 格式将内容嵌入到作为 MTOM 一部分的 xml 中SOAP 中使用的协议,但我没有看到直接通过 REST 提供 XML+XOP 响应的解决方案。

我的问题:有人可以给我提示如何使用 Jersey / spring 实现 XOP + REST 吗?我看到过一些帖子暗示有人以前做过...

最诚挚的问候,
蒂姆

I've been given the task to embed binary data (like pictures, music, thumbnails etc) into a xml metadata container in order to publish the whole package via REST interface. Currently we're using Jersey and spring in our project.
I really don't want to fall back to soap/wsdl (which seems to be the default answer for every ws-based problem) or any container format like zip just to get that data over the wire so i googled a while for a more appropriate solution.

I found out that recommends the XOP format for embedding content into xml which is part of the MTOM protocol used in SOAP but I don't see a solution that provides XML+XOP responses via REST directly.

My question: can someone give me a hint how to implement XOP + REST by using Jersey / spring? I've seen posts that imply that someone has done it before...

Best regards,
tim

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

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

发布评论

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

评论(2

大海や 2024-10-14 12:37:31

为什么要将二进制数据嵌入到 XML 中?有很多方法可以将二进制资源与其相应的元数据相关联,而无需尝试将其填充到单个表示中。

您正在破坏 REST HTTP 的主要优势之一。根据需求处理多种不同媒体类型的能力是使用 REST over HTTP 比 SOAP 更有效的原因之一。

考虑像 Atom 一样检索包含二进制资源链接的元数据的 XML 表示形式。如果您想首先检索二进制文件,请考虑链接标头指向元数据。有很多比尝试将二进制数据填充到 XML 中更好的方法。

Why would you want to embed binary data into XML? There are plenty of ways to associate binary resources to their corresponding metadata without trying to stuff it into a single representation.

You are defeating one of the primary benefits of REST HTTP. The ability to handle multiple different media-types based on the requirements is one of the reasons using REST over HTTP can be more effective than SOAP.

Consider retrieving an XML representation of the metadata that contains a link to the binary resource as Atom does. If you want to retrieve the binary first, then consider Link Headers to point to the metadata. There are lots of better ways than trying to stuff binary data into XML.

忆梦 2024-10-14 12:37:31

我不确定 Jersey,但 CXF 支持 XOP。也许你可以从那里获得灵感?

http://cxf.apache.org/docs/jax -rs-multiparts.html#JAX-RSMultiparts-XOPsupport

I'm not sure about Jersey, but CXF has support for XOP. Perhaps you can take inspiration from there?

http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-XOPsupport

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