users@jsr311.java.net

Re: JAXB + XOP

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 04 Aug 2008 13:02:34 +0200

Dmitry Repchevsky wrote:
> Hello Paul,
>
> If I understand it correctly, now I have to implement
> AttachmentMarshaller/Unmarshaller to read/write an attachment and
> use ContextResolver//<JAXBContext> to inject my JAXBContext (with
> implemented AttachmentMarshaller/Unmarshaller).
> But how con I get an attachment (from AttachmentMarshaller/Unmarshaller)?
>
> Could you illuminate please?
>

You can use a MimeMultipart instance. The AttachmentMarshaller and
AttachmentUnmarshaller implementation would get/set body parts on the
MimeMultipart instance.


>> Thus you could add support for XOP, as hinted above using JavaMail, or
>> another way is to use JAXB [2].
>>
> I know about AttachmentUnmarshaller, but JAX-WS set it automatically
> then MTOM is enabled.

Right, it is an important aspect of SOAP-based Web services, but for
RESTful Web services it is not so important, as there are better,
clearer and more efficient ways to transmit binary information.


> I think that it would be great if JAX-RS do the same when
> MessageBodyReader is a JAXBObject.
>

It is definitely possible to write your own reader/writer to operate on
the media type "application/xop+xml" and a JAXB object type as we have
been discussing. However, i have strong reservations against mandating
that such support be required by JAX-RS implementations.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109