开发者

rest + xop / binary data embedded in xml response

I've been given the task to embed binary data (lik开发者_Python百科e 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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜