cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kulp (JIRA)" <>
Subject [jira] [Commented] (CXF-5832) JAX-WS Provider returning JAXBSource with attachment
Date Wed, 02 Jul 2014 20:32:24 GMT


Daniel Kulp commented on CXF-5832:

I'm really not expecting this to work.     The OUTBOUND_MESSAGE_ATTACHMENTS is really a temporary
wrapper around the internal List<Attachment> that is only valid for the scope of the
invoke method.  Once that returns, it's removed.

HOWEVER, if you do something like:
//force the runtime to create the response message

//Get the outbound message created above
Message m = PhaseInterceptorChain.getCurrentMessage().getExchange().getOutMessage();
//get or create the List<Attachments>
List<Attachment>  attachments = (List)m.get(Message.ATTACHMENTS);
if (attachments == null) {
    attachments = new ArrayList<Attachment>();
    m.put(Message.ATTACHMENTS, attachments)

marshaller.setAttachmentMarshaller(new org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller(attachments,
return new JAXBSource(marshaller, obj);
then I believe it would work as it would use the same internal structures we use and would
survive outside the scope of the invoke method.

> JAX-WS Provider returning JAXBSource with attachment
> ----------------------------------------------------
>                 Key: CXF-5832
>                 URL:
>             Project: CXF
>          Issue Type: Improvement
>          Components: Bus, Core, JAX-WS Runtime
>    Affects Versions: 3.0.0
>            Reporter: Zsolt Szloboda
>            Priority: Minor
> I am trying to return a JAXBSource payload from a JAX-WS Provider; 
> the JAXBSource's Marshaller has a custom AttachmentMarshaller 
> that puts the attachments into the MessageContext's OUTBOUND_MESSAGE_ATTACHMENTS Map

> the problem is that the attachments are not included in the response multipart SOAP message

> however, if I transform the same JAXBSource result payload 
> into a DOMSource, and return this DOMSource from the Provider#invoke() method, 
> then the attachments are included in the response multipart SOAP message! 
> I think the problem is that 
> when I return the JAXBSource 
> the attachments are added "too late" 
> (when the JAXBSource is processed by the CXF runtime, outside of the Provider#invoke()
> to the MessageContext 
> am I right, if I think that this means 
> that CXF currently does not support 
> JAXBSource payload results *with attachments*? 
> which means that we have to build an unnecessary DOM tree in these cases... 

This message was sent by Atlassian JIRA

View raw message