You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by cmoulliard <cm...@gmail.com> on 2008/03/10 13:42:41 UTC

Simplest solution to transform XML to POJO & POJO to XML ?

Hi,

I see on the forum a lot of discussion using servicemix-bean or
servicemix-jsr181 as SE but nothing concerning the simplest way to map the
XML received through a normalized message to a POJO bean or back from a POJO
bean to normalized message ?

JSR181 uses JAXB2 or AEGIS to map XML to POJO or POJO to XML but JSR181
exposes the service as a web service. In this case, the work of the
developer is simplied. Comparatively, exposing a POJO to the bus, seems less
complicate because WSDL is not required. But How can we map XML to POJO or
POJO to XML (using XStream, Aegis, ...) Do servicemix provide helper or util
classes to perform this ?

Can someone provide a java example demonstrating how to achieve (XML to POJO
vs POJO to XML) this through servicemix-bean ?

Regards,

Charles
-- 
View this message in context: http://www.nabble.com/Simplest-solution-to-transform-XML-to-POJO---POJO-to-XML---tp15950722s12049p15950722.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Simplest solution to transform XML to POJO & POJO to XML ?

Posted by cmoulliard <cm...@gmail.com>.
Gert,

Many thanks for your answer. What you propose is exactly what I was looking
for and avoid to reinvent the wheel. I have started to read Camel
documentation. 

One additional question that I want to ask you is the following :

Which strategy do you propose or recommend to orchestrate the services
together : camel or BPEL or ... ? BPEL which is WSDL centric is much more
integrated in Eclipse or Netbeans to design workflow than Camel ? Is it
right ? 

Do you recommend that between the different tasks of the workflow, the
information is persisted into queue engine (MQ, ActiveMq, ...) ?

ex :
Files --> extract orders --> place them on a queue as messages --> read the
message from the queue and parse the SWIFT MT502 (task 1) --> persist the
result on a queue --> read the string from the queue and generate POJO class
--> persist the serialized object on a queue --> read the javaz object from
the queue and transform the POJO order into a generic Fund POJO --> persist
the result on a queue --> read the message from the queue and commit it info
into database

Is it a interesting strategy or should I have to group tasks together (like
generate POJO class from SWIFT202 --> Transform it into a Find POJO -->
commit it to the DB) ? If the tasks are grouped, can servicemix guaranty
that in case of rollback, the messages will be pushed back to the queueing
engine and the DB will be rollbacked ? If the tasks are grouped together in
a SU, do you recommend to use BPEL to define the workflow between the tasks
?

Regards,

Charles


Gert Vanthienen wrote:
> 
> Charles,
> 
> 
> Within a servicemix-bean service, you can basically use any technology 
> for POJO <-> XML transformation.  I usually use JAXB myself, but 
> anything will work there.  I don't think there are many helper classes 
> in ServiceMix for doing that.  One helper class that is available 
> however is the XStreamSource is .  This one was designed to allow you to 
> just use getObject/setObject on the Source object to transfer a POJO and 
> it will use XStream to make to (un)marshal it from/to XML.
> 
> Perhaps you should also take a look at Apache Camel's support for 
> working with different data formats 
> (http://activemq.apache.org/camel/data-format.html).  There are a few 
> links to code examples there that show you how to use the Java DSL to 
> specify routes which include data format transformation (such as JAXB, 
> XStream, ...).  You can quite easily start using Camel inside ServiceMix 
> with the servicemix-camel component (basic tutorial on using this 
> component is work in progress -- have a sneak preview at 
> http://servicemix.apache.org/3-beginner-using-apache-camel-inside-servicemix.html)
> 
> 
> Gert
> 
> cmoulliard wrote:
>> Hi,
>>
>> I see on the forum a lot of discussion using servicemix-bean or
>> servicemix-jsr181 as SE but nothing concerning the simplest way to map
>> the
>> XML received through a normalized message to a POJO bean or back from a
>> POJO
>> bean to normalized message ?
>>
>> JSR181 uses JAXB2 or AEGIS to map XML to POJO or POJO to XML but JSR181
>> exposes the service as a web service. In this case, the work of the
>> developer is simplied. Comparatively, exposing a POJO to the bus, seems
>> less
>> complicate because WSDL is not required. But How can we map XML to POJO
>> or
>> POJO to XML (using XStream, Aegis, ...) Do servicemix provide helper or
>> util
>> classes to perform this ?
>>
>> Can someone provide a java example demonstrating how to achieve (XML to
>> POJO
>> vs POJO to XML) this through servicemix-bean ?
>>
>> Regards,
>>
>> Charles
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://www.anova.be
> 

-- 
View this message in context: http://www.nabble.com/Simplest-solution-to-transform-XML-to-POJO---POJO-to-XML---tp15950722s12049p15976655.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Simplest solution to transform XML to POJO & POJO to XML ?

Posted by Gert Vanthienen <ge...@skynet.be>.
Charles,


Within a servicemix-bean service, you can basically use any technology 
for POJO <-> XML transformation.  I usually use JAXB myself, but 
anything will work there.  I don't think there are many helper classes 
in ServiceMix for doing that.  One helper class that is available 
however is the XStreamSource is .  This one was designed to allow you to 
just use getObject/setObject on the Source object to transfer a POJO and 
it will use XStream to make to (un)marshal it from/to XML.

Perhaps you should also take a look at Apache Camel's support for 
working with different data formats 
(http://activemq.apache.org/camel/data-format.html).  There are a few 
links to code examples there that show you how to use the Java DSL to 
specify routes which include data format transformation (such as JAXB, 
XStream, ...).  You can quite easily start using Camel inside ServiceMix 
with the servicemix-camel component (basic tutorial on using this 
component is work in progress -- have a sneak preview at 
http://servicemix.apache.org/3-beginner-using-apache-camel-inside-servicemix.html)


Gert

cmoulliard wrote:
> Hi,
>
> I see on the forum a lot of discussion using servicemix-bean or
> servicemix-jsr181 as SE but nothing concerning the simplest way to map the
> XML received through a normalized message to a POJO bean or back from a POJO
> bean to normalized message ?
>
> JSR181 uses JAXB2 or AEGIS to map XML to POJO or POJO to XML but JSR181
> exposes the service as a web service. In this case, the work of the
> developer is simplied. Comparatively, exposing a POJO to the bus, seems less
> complicate because WSDL is not required. But How can we map XML to POJO or
> POJO to XML (using XStream, Aegis, ...) Do servicemix provide helper or util
> classes to perform this ?
>
> Can someone provide a java example demonstrating how to achieve (XML to POJO
> vs POJO to XML) this through servicemix-bean ?
>
> Regards,
>
> Charles
>