You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alex <de...@gmail.com> on 2009/12/14 10:49:05 UTC

soap with attachments mime dime

hi,

I have to implement a webservice which must be able to receive attachments.
The attachments are encoded in MIME or DIME, all attachments are send 
via SWA Soap With Attachments (not MTOM).
I tested the webservice with SOAPUI and attached a PDF-File to the 
request, and it seems that the server will receive the attachment.

But I have now idea how to work with the attachemnt on the server side, 
have I use AttachmentInInterceptor?

Thank you, Alex


Re: soap with attachments mime dime

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 13 July 2010 5:38:54 am erskine wrote:
> Hi.
> 
> I tried putting my attachments using
> MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS or using Message.Attachments. 
> I can see the attachments in the requestContext, but they do not get
> automatically added to the message object's attachment collection.  So a
> call to message.getAttachments() returns null.

What version of CXF?   I'm not seeing anything obvious in the code on trunk, 
especially for the Message.ATTACHMENTS case.   It looks like it should just 
get added to the message from the context as is.   

Can you create a small sample?

Dan

> 
> Any idea why this is so?
> 
> I have to write my own interceptor and populate the message object with the
> attachments from the requestObject.
> 
> kin

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

Re: soap with attachments mime dime

Posted by Glen Mazza <gl...@gmail.com>.

erskine wrote:
> 
> I tried putting my attachments using
> MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS or using Message.Attachments. 
> I can see the attachments in the requestContext, but they do not get
> automatically added to the message object's attachment collection.  So a
> call to message.getAttachments() returns null.
> 

Just a guess--if you're using JAX-WS handlers (instead of CXF interceptors),
make sure you set the SCOPE to APPLICATION and not just HANDLER, so the
client or service endpoints will receive whatever you attach:
http://www.jroller.com/gmazza/entry/jaxws_handler_tutorial

HTH,
Glen

-- 
View this message in context: http://cxf.547215.n5.nabble.com/soap-with-attachments-mime-dime-tp568705p1046879.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: soap with attachments mime dime

Posted by erskine <er...@gmail.com>.
Hi.

I tried putting my attachments using
MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS or using Message.Attachments.  I
can see the attachments in the requestContext, but they do not get
automatically added to the message object's attachment collection.  So a
call to message.getAttachments() returns null.

Any idea why this is so?

I have to write my own interceptor and populate the message object with the
attachments from the requestObject.

kin
-- 
View this message in context: http://cxf.547215.n5.nabble.com/soap-with-attachments-mime-dime-tp568705p1046655.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: soap with attachments mime dime

Posted by Daniel Kulp <dk...@apache.org>.
On Mon December 14 2009 5:18:44 pm Alex wrote:
> hi,
> 
> how can I send attachments (no mtom) from the client, is there a
> possibility to specify the typ (mime or dime).

We don't support dime.

I THINK you can do something similar using:

((BindingProvider)port).getRequestContext().put(...)

to put a map of attachments onto the request context to send.     Probably 
MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, but not 100% sure.

Dan


> 
> thanks Alex
> 
> Daniel Kulp schrieb:
> > On Mon December 14 2009 4:49:05 am Alex wrote:
> >> hi,
> >>
> >> I have to implement a webservice which must be able to receive
> >> attachments. The attachments are encoded in MIME or DIME, all
> >> attachments are send via SWA Soap With Attachments (not MTOM).
> >> I tested the webservice with SOAPUI and attached a PDF-File to the
> >> request, and it seems that the server will receive the attachment.
> >>
> >> But I have now idea how to work with the attachemnt on the server side,
> >> have I use AttachmentInInterceptor?
> >
> > The AttachmentInInterceptor is automatically there.  Nothing you need to
> > do from that standpoint.
> >
> > Where do you WANT to work with the attachments?  In an interceptor or in
> > your service implementation?
> >
> > If in an interceptor, the message passed in has a getAttachments() call.
> >
> > In an implementation, the WebServiceContext can be used.   The STANDARD
> > JAX-WS way would be:
> >
> > @Resource
> > WebServiceContext ctx
> >
> > .....
> >
> > Map<String, DataHandler> map = (Map)
> > ctx.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
> >
> > which would work fine.
> >
> > You can then iterate through the map to find your attachment and such.
> 

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

Re: soap with attachments mime dime

Posted by Alex <de...@gmail.com>.
hi,

how can I send attachments (no mtom) from the client, is there a 
possibility to specify the typ (mime or dime).

thanks Alex

Daniel Kulp schrieb:
> On Mon December 14 2009 4:49:05 am Alex wrote:
>> hi,
>>
>> I have to implement a webservice which must be able to receive attachments.
>> The attachments are encoded in MIME or DIME, all attachments are send
>> via SWA Soap With Attachments (not MTOM).
>> I tested the webservice with SOAPUI and attached a PDF-File to the
>> request, and it seems that the server will receive the attachment.
>>
>> But I have now idea how to work with the attachemnt on the server side,
>> have I use AttachmentInInterceptor?
>
> The AttachmentInInterceptor is automatically there.  Nothing you need to do 
> from that standpoint.
>
> Where do you WANT to work with the attachments?  In an interceptor or in your 
> service implementation?    
>
> If in an interceptor, the message passed in has a getAttachments() call.   
>
> In an implementation, the WebServiceContext can be used.   The STANDARD JAX-WS 
> way would be:
>
> @Resource
> WebServiceContext ctx
>
> .....
>
> Map<String, DataHandler> map = (Map) 
> ctx.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
>
> which would work fine.
>
> You can then iterate through the map to find your attachment and such.
>
>


Re: soap with attachments mime dime

Posted by Alex <de...@gmail.com>.
thank you Daniel for your help,

the example you mentioned works, but I still getting warnings like:
Unchecked cast from Object to Map<String,DataHandler>
I am not sure what's the recommended java version fpr apache xcf.
I'am using jdk 1.6.0.17 with apach xcf 2.2.5

Do you have any idea.

Thank you Alex


Daniel Kulp schrieb:
> On Mon December 14 2009 4:49:05 am Alex wrote:
>> hi,
>>
>> I have to implement a webservice which must be able to receive attachments.
>> The attachments are encoded in MIME or DIME, all attachments are send
>> via SWA Soap With Attachments (not MTOM).
>> I tested the webservice with SOAPUI and attached a PDF-File to the
>> request, and it seems that the server will receive the attachment.
>>
>> But I have now idea how to work with the attachemnt on the server side,
>> have I use AttachmentInInterceptor?
>
> The AttachmentInInterceptor is automatically there.  Nothing you need to do 
> from that standpoint.
>
> Where do you WANT to work with the attachments?  In an interceptor or in your 
> service implementation?    
>
> If in an interceptor, the message passed in has a getAttachments() call.   
>
> In an implementation, the WebServiceContext can be used.   The STANDARD JAX-WS 
> way would be:
>
> @Resource
> WebServiceContext ctx
>
> .....
>
> Map<String, DataHandler> map = (Map) 
> ctx.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
>
> which would work fine.
>
> You can then iterate through the map to find your attachment and such.
>
>


Re: soap with attachments mime dime

Posted by Daniel Kulp <dk...@apache.org>.
On Mon December 14 2009 4:49:05 am Alex wrote:
> hi,
> 
> I have to implement a webservice which must be able to receive attachments.
> The attachments are encoded in MIME or DIME, all attachments are send
> via SWA Soap With Attachments (not MTOM).
> I tested the webservice with SOAPUI and attached a PDF-File to the
> request, and it seems that the server will receive the attachment.
> 
> But I have now idea how to work with the attachemnt on the server side,
> have I use AttachmentInInterceptor?

The AttachmentInInterceptor is automatically there.  Nothing you need to do 
from that standpoint.

Where do you WANT to work with the attachments?  In an interceptor or in your 
service implementation?    

If in an interceptor, the message passed in has a getAttachments() call.   

In an implementation, the WebServiceContext can be used.   The STANDARD JAX-WS 
way would be:

@Resource
WebServiceContext ctx

.....

Map<String, DataHandler> map = (Map) 
ctx.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);

which would work fine.

You can then iterate through the map to find your attachment and such.


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