cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Attachments
Date Mon, 20 Apr 2009 17:44:17 GMT

Couple of ways to do it:

JAX-WS standard way would be through the WebserviceContext:

context.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)

which would return a Map<String, DataHandler>


Semi CXF specific: you can use the WebServiceContext, but cast to the specific 
CXF type and get the AttachmentList.   That avoids some of the conversion that 
the above would do and enables better streaming:

((org.apache.cxf.jaxws.context.WrappedMessageContext)context.getMessageContext()).getWrappedMessage().getAttachments()

That would return Collection<org.apache.cxf.message.Attachment>.


Another option with 2.2:
PhaseInterceptorChain.getCurrentMessage().getAttachments();



Dan




On Sun April 19 2009 6:21:24 pm John Baker wrote:
> Hello,
>
> What's the quickest/easiest way to get attachments from a SOAP call in CXF?
>
> Do we have to use an interceptor, as detailed here:
> http://cwiki.apache.org/CXF20DOC/interceptors.html
>
> Or is there an easier way, using a WebserviceContext perhaps?
>
> This is the Apache way, which is fairly triival:
>
>
> org.apache.axis.MessageContext context =
>    org.apache.axis.MessageContext.getCurrentContext();
> Message message = context.getRequestMessage();
> Iterator<AttachmentPart> i = message.getAttachments();
>
> Thanks
>
>
> John

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Mime
View raw message