Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-205

Add support for XML-binary Optimized Packaging (XOP), to be able to produce/consume "application/xop+xml"

    XMLWordPrintable

Details

    Description

      Its always a pain if you have to work with messages that should hold xml and binary content too. SOAP has it support to do so using mtom/xop, but XOP is not a SOAP only technology. See nosoap example in the specification [1].

      Resteasy already support multipart input/output which is great but its a bit limited if you want to use a complex object graph. JAXB has a built in extension point for xop message creation. See AttachmentMarshaller [2] and AttachmentUnmarshaller [3]. These are abstract classes, which need to be extended and configured on Marshaller [4] and Unmarshaller [5] so JAXB can use them while marshalling/unmarshalling.

      Imho a resteasy implementation would add a new MediaType for xop (application/xop+xml) and use a special provider to handle it. It would also consist a new Annotation, like MultipartForm and Form to mark parameters/return values for marshalling/unmarshalling.
      The producer implementation would consist an AttachmentMarshaller to get the references of binary content and to generate cids. The provider would create a jaxbcontext, configure it with the AttachmentMarshaller and let the jaxb marshall the object graph. After that it could use the already implemented multipartprovider to output the xml and the binary parts as a multipart message.
      The consumer implementation would consist an AttachmentUnmarshaller to feed the jaxb with the binary attachments. The provider would use already implemented multipartprovider to parse the input and to configure an instance of AttachmentUnmarshaller with it. Using that instance with a jaxb unmarshaller it could unmarshall the input into an object tree.

      References:
      1 XOP nosoap example in spec: http://www.w3.org/TR/2005/REC-xop10-20050125/#xml_infoset_xml_sample
      2 AttachmentMarshaller javadoc: http://java.sun.com/javase/6/docs/api/javax/xml/bind/attachment/AttachmentMarshaller.html
      3 AttachmentUnmarshaller javadoc: http://java.sun.com/javase/6/docs/api/javax/xml/bind/attachment/AttachmentUnmarshaller.html
      4 Marshaller.setAttachmentMarshaller javadoc: http://java.sun.com/javase/6/docs/api/javax/xml/bind/Marshaller.html#setAttachmentMarshaller(javax.xml.bind.attachment.AttachmentMarshaller)
      5 Unmarshaller.setAttachmentUnmarshaller javadoc: http://java.sun.com/javase/6/docs/api/javax/xml/bind/Unmarshaller.html#setAttachmentUnmarshaller(javax.xml.bind.attachment.AttachmentUnmarshaller)

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            akiraly Attila Király (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: