-
1. Re: Unmarshal JSON to XML using Spring DSL
davsclaus Apr 12, 2012 3:19 AM (in response to smalson)A side note.
A new component is coming in Camel 2.10, that can map directly between XML <-> JSon, camel-xmljson
Currently its in development, and we dont have any documentation yet. The source code is here:
https://svn.apache.org/repos/asf/camel/trunk/components/camel-xmljson/
The json data format uses XStream, that uses Jettison. So I guess the XStream project has better documentation:
http://xstream.codehaus.org/index.html
The Camel XML DSL has a data format that have options for configuring XStream. I wonder if any of those can help to configure it to map JSon to XML without any POJOs
-
2. Re: Unmarshal JSON to XML using Spring DSL
smalson Apr 19, 2012 3:27 PM (in response to davsclaus)I was able to create a Bean which wrapped the Jettison library and use it as a Transform. That worked with the exception that it does not handle JSON arrays the way I expected. I built the camel-xmljson project as a Bundle and deployed in ServiceMix4.4.1, but I need to know how to include the dependencies. I get the following error:
karaf@root> bundles:start 188
org.osgi.framework.BundleException: Unresolved constraint in bundle camel-xmljson : Unable to re
solve 188.1: missing requirement package; (package=net.sf.json)
I am relatively new to ServiceMix and would like to know the best way to include the dependencies that are not in ServiceMix (i.e. json-lib.jar). I did notice there is also a patch for Camel that includes the camel-xmljson. Would it be a better option to go about applying the diff to camel 2.8.4 release?
-
3. Re: Unmarshal JSON to XML using Spring DSL
ffang Apr 19, 2012 7:14 PM (in response to smalson)Hi,
Basically FUSE ESB/Servicemix is also an OSGi container, so you can install json-lib.jar as a bundle in FUSE ESB before you install camel-xmljson bundle.
Freeman
-
4. Re: Unmarshal JSON to XML using Spring DSL
raul.kripalani Apr 20, 2012 7:35 AM (in response to smalson)Hi smaison,
Typically you would install the camel-xmljson ServiceMix feature. A feature is a group of bundles, other features and configuration entries. By installing the feature, ServiceMix will take care of installing whatever is needed to make the component work.
We have provided a camel-xmljson feature which you can install using the following command:
features:install camel-xmljson/2.10-SNAPSHOT
Previously, you should have added the features repository by using the following command:
features:addurl mvn:org.apache.camel.karaf/apache-camel/2.10-SNAPSHOT/xml/features
(provided that your SMX instance is configured to access public SNAPSHOT repositories, which it is if you're running the default config)
However, I do not recommend doing this at this point, as it will drag along camel-core 2.10, camel-spring 2.10, etc. etc. etc. So an entire Camel 2.10 runtime will be installed along with any dependencies. This could mess you things for you. Instead, you probably want to make the component work with whatever version of Camel you're on.
So instead, run the following sequence of commands to install the dependencies one-by-one:
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-beanutils/1.8.3_1
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.oro/2.0.8_6
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ezmorph/1.0.6_1-SNAPSHOT
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.json-lib/2.4_1-SNAPSHOT
And, finally:
install -s mvn:org.apache.camel/camel-xmljson/2.10-SNAPSHOT
And you should be good to go! (no need to build camel-xmljson locally even... as the SNAPSHOT is already available in the public Maven repos!)
Hope that helps.
Regards,
Raúl.