You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ousti <bi...@gmail.com> on 2011/08/03 07:40:46 UTC
[JAXB] Object containing XML
Hello,
I have one java object Y containing xml in one of its properties String X.
I want to unmarshal what is contained in X but also preserve the other items
contained in my object Y.
I know camel has a getIn.setBody(X) property where i can set the body to X
and then unmarshall it by calling unmarshall(myjaxb).
However by doing this i will loose my object other properties. Is there a
way to:
1. send only X to the unmarshall method
2. put this unmarshalled result within a property of my object Y
3. put back the object Y as camel message body such as getIn.setBody(Y).
--
View this message in context: http://camel.465427.n5.nabble.com/JAXB-Object-containing-XML-tp4661299p4661299.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: [JAXB] Object containing XML
Posted by Willem Jiang <wi...@gmail.com>.
On 8/3/11 1:40 PM, ousti wrote:
> Hello,
>
> I have one java object Y containing xml in one of its properties String X.
>
> I want to unmarshal what is contained in X but also preserve the other items
> contained in my object Y.
>
> I know camel has a getIn.setBody(X) property where i can set the body to X
> and then unmarshall it by calling unmarshall(myjaxb).
>
> However by doing this i will loose my object other properties. Is there a
> way to:
> 1. send only X to the unmarshall method
> 2. put this unmarshalled result within a property of my object Y
> 3. put back the object Y as camel message body such as getIn.setBody(Y).
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JAXB-Object-containing-XML-tp4661299p4661299.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
You can put the object Y into message header, and X as the message body.
Then you can put object Y into the message body and set the property of
Y with unmarshaed value in your customer processor.
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Re: [JAXB] Object containing XML
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Aug 3, 2011 at 7:40 AM, ousti <bi...@gmail.com> wrote:
> Hello,
>
> I have one java object Y containing xml in one of its properties String X.
>
> I want to unmarshal what is contained in X but also preserve the other items
> contained in my object Y.
>
> I know camel has a getIn.setBody(X) property where i can set the body to X
> and then unmarshall it by calling unmarshall(myjaxb).
>
> However by doing this i will loose my object other properties. Is there a
> way to:
> 1. send only X to the unmarshall method
> 2. put this unmarshalled result within a property of my object Y
> 3. put back the object Y as camel message body such as getIn.setBody(Y).
>
If you have camel-jaxb on the classpath, then the type converter
system should be able to convert any object to/from XML if they have
been properly JAXB annotated.
Something like:
Object x = ... get the X from the body
MyObject myX = exchange.getContext().getTypeConverter().convertTo(MyObject.class,
x);
> --
> View this message in context: http://camel.465427.n5.nabble.com/JAXB-Object-containing-XML-tp4661299p4661299.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/