camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: How to enrich message with the result of other invocation
Date Wed, 31 Oct 2007 16:22:48 GMT
On 30/10/2007, James Strachan <james.strachan@gmail.com> wrote:
> On 29/10/2007, Roman Kalukiewicz <roman.kalukiewicz@gmail.com> wrote:
> > Hello!
> >
> > I'm looking for elegant solution for following problem:
> >
> > I receive request that is an XML document or object. I need to enrich
> > it (add new element or set a property). The problem is that the value
> > I want to enrich with is the result of some endpoint invocation.
> >
> > I know that I can do it using custom processor, but maybe there is
> > some Expression instance that evaluates to result of endpoint
> > invocation? this way I can simply use setBody() or setHeader() methods
> > with such Expression.
> >
> > Or maybe there is better way to do it? I'm just curious if I can avoid
> > using custom processors and express everything in DSL.
>
> Interesting use case! :) Am sure over time we'll figure out nicer and
> richer ways of putting all kinds of things like this into the DSL.
>
> I wonder if we could expose 'invoke an endpoint' nicely inside XSLT or
> XQuery to make it easy to enrich messages that way?
>
> Am sure we could do something like
>
> let $doc := .
> for $invoke in camel-invoke("some-uri")/*
> return <result>{ $doc, $invoke }</result >
>
> I couldn't see an easy way to use XQuery to say effectively, 'add the
> XQuery expression into the context node as a child' - am sure with
> more XQuery ninja there's a way to do it a bit cleaner.

A maybe cleaner way to do it in XQuery is something like this...

<result>
{/*}
{camel-invoke('some-uri')}
</result>

This will embed the original document inside <result> then the result
of the camel-invoke method in there too.

I've not seen a cleaner way to put the invocation inside the first
child of the input yet though.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com

Mime
View raw message