You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Roderic Green <cx...@gmail.com> on 2009/04/01 07:52:24 UTC

Re: Non-MTOM attachment NOT defined in WSDL

Thanks for you answer Daniel,

  Attachment I need to send is different for each WS method invocation (it
is like an additional merthod argument). Are interceptors designed for such
use? What about synchronisation etc.



-- 

Roderic

2009/3/31 Daniel Kulp <dk...@apache.org>

>
> It's definitely doable with an Interceptor.   If you want to write an
> interceptor (not hard) that runs in an early phase (like user_logical),
> then
> you can do it.  The interceptor's handleMessage call would look something
> like:
>
>        message.getInterceptorChain().add(new AttachmentOutInterceptor());
>        message.put(AttachmentOutInterceptor.WRITE_ATTACHMENTS,
> Boolean.TRUE);
>
>        Collection<Attachment> atts = message.getAttachments();
>        if (atts == null) {
>            atts = new ArrayList<Attachment>();
>            message.setAttachments(atts);
>        }
>        atts.add(.......);
>
> Basically, the Collection<Attachment> thing is where you would add your
> attachment.  The AttachmentOutInterceptor (which is probably already on the
> chain so you MAY be able to skip that) is what will write it out.
>
> Dan
>
>
>
> On Tue March 31 2009 2:56:45 am Roderic Green wrote:
> > Thank your for your answer.
> >
> > Does it mean, that I have to modify wsdl and add a new parameter for data
> I
> > want to be sent as attachment?
> >
> > And - is there any documentation on how to use CXF with services which
> > don't support MTOM ?
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Non-MTOM attachment NOT defined in WSDL

Posted by Daniel Kulp <dk...@apache.org>.
On Wed April 1 2009 1:52:24 am Roderic Green wrote:
> Thanks for you answer Daniel,
>
>   Attachment I need to send is different for each WS method invocation (it
> is like an additional merthod argument). Are interceptors designed for such
> use? What about synchronisation etc.

Well, they CAN be.   Normally what you would do in your interceptor it grab a 
property from the message via something like:

MyObject o = (MyObject)message.getContextualProperty("my.object.key");

and use that in your interceptor.


Your client code would do something like:

((BindingProvider)proxy).getRequestContext().put("my.object.key", myObject);

to add the object into the context so the interceptor can grab it.     


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