Suggestion required: RESTFUl webservice transform xml to Json

Hi I am new to Java and not sure how to proceed (kindly ignore any typos or my language). Can somebody help me out (just the Idea/how to proceed, dont need any sample code). I am trying to create a Restful Json webservice (using Spring MVC). The webservice that I am trying to create is kind of a wrapper for an existing XML based restful webservice. The Idea is to have one common platform, since all other existing services are exposed as as JSON services. My job is to fetch the XML transform it into a Json, but the tricky part is The Json schema is a superset of the XML schema (I mean it contains more elements that get filled with some default values). Please let me know if you need more info.

Thanks in advance.

Answers


One way to do it would be to use Jaxb to transform the the incoming XML to Java Objects. Build your Jaxb objects in a way that it contains all the elements, the one with default values and the elements in the incoming XML.

Ones the XMl is converted into Jaxb you can use org.springframework.http.converter.json.MappingJacksonHttpMessageConverter message converter to convert your Jaxb object to Json string.


Need Your Help

IE7 and 8 CSS menu background dropdown hover issue

css internet-explorer twitter-bootstrap

Hoping someone can help with a fresh pair of eyes, have been banging my head against a brick wall trying to fix an issue in IE7-8 where dropdown menu items jump around when hovered over - some nega...

Combo boxes do not show records on 2nd load of window

combobox extjs

been struggling with an issue now for a day or two. I have an Ext.Window that contains 2 combo-boxes. on the first load everything works fine, both stores are populated and the combo's work as they