Sorry, I keep answering my own mail. What I did is override JAXBElementProvider with an implementation of addAttachmentMarshaller() using org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller instead of the default org.apache.cxf.jaxrs.provider.JAXBAttachmentMarshaller. That seems to solve the problem.
The response looks like: ============================= --uuid:f118c4d3-aa61-473c-8c93-0a3101e7e878 Content-Type: application/xml Content-Transfer-Encoding: binary Content-ID: <ma> <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Customer><email>[email protected]</email></Customer> --uuid:f118c4d3-aa61-473c-8c93-0a3101e7e878 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-ID: <[email protected]> ..... ..... ============================ Does this seem correct in terms of how swaref should work? (email field in the root attachment) What's the reason org.apache.cxf.jaxrs.provider.JAXBAttachmentMarshaller does not implement addSwaRefAttachment()? -Vinay -----Original Message----- From: Penmatsa, Vinay [mailto:[email protected]] Sent: Tuesday, May 14, 2013 1:46 PM To: [email protected] Subject: RE: JAX-RS XmlAttachmentRef Oh I see...MTOM is enabled for @XMLElement. That's why it works. Is swaref with @XMLAttachmentRef not supported? -----Original Message----- From: Penmatsa, Vinay [mailto:[email protected]] Sent: Tuesday, May 14, 2013 12:49 PM To: [email protected] Subject: JAX-RS XmlAttachmentRef Hi Using CXF 2.6.1, @XmlAttachmentRef private DataHandler email; produces the following error: Caused by: java.lang.UnsupportedOperationException at org.apache.cxf.jaxrs.provider.JAXBAttachmentMarshaller.addSwaRefAttachment(JAXBAttachmentMarshaller.java:73) at com.sun.xml.bind.v2.runtime.SwaRefAdapter.marshal(SwaRefAdapter.java:84) at com.sun.xml.bind.v2.runtime.SwaRefAdapter.marshal(SwaRefAdapter.java:69) at com.sun.xml.bind.v2.runtime.reflect.AdaptedAccessor.get(AdaptedAccessor.java:76) ... 42 more If I do this, @XmlElement private DataHandler email; it seems to work fine. There's a org.apache.cxf.jaxb.attachment. JAXBAttachmentMarshaller that implements the addSwaRefAttachment() method. Somewhat confused what's happening. Also, I need to support a list of attachments like say List<DataHandler>. Does that work? Thanks, Vinay
