1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.cxf.support;
12
13 import org.mule.api.MuleEvent;
14 import org.mule.api.MuleMessage;
15 import org.mule.module.cxf.CxfConstants;
16 import org.mule.transport.http.HttpConstants;
17
18 import java.util.Collection;
19
20 import org.apache.cxf.interceptor.Fault;
21 import org.apache.cxf.message.Attachment;
22 import org.apache.cxf.message.Message;
23 import org.apache.cxf.phase.AbstractPhaseInterceptor;
24 import org.apache.cxf.phase.Phase;
25
26 public class CopyAttachmentInInterceptor extends AbstractPhaseInterceptor
27 {
28 public CopyAttachmentInInterceptor()
29 {
30 super(Phase.PRE_INVOKE);
31 }
32
33 public void handleMessage(Message message) throws Fault
34 {
35 MuleEvent event = (MuleEvent) message.getExchange().get(CxfConstants.MULE_EVENT);
36 MuleMessage muleMsg = event.getMessage();
37 Collection<Attachment> atts = message.getAttachments();
38 if (atts != null)
39 {
40 muleMsg.setInvocationProperty(CxfConstants.ATTACHMENTS, atts);
41 muleMsg.setOutboundProperty(HttpConstants.HEADER_CONTENT_TYPE, muleMsg.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE));
42 }
43 }
44
45 }
46
47