Announcement Announcement Module
No announcement yet.
Marshalling entities with the same root name Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Marshalling entities with the same root name


    I am in a project where we're building synchorization services to an external system using RESTful web service calls through RestTemplate. The external system gives us three entities: places, events and members, through three different uri's. The problem is that the XML-structure for all three entities has the top-level tag "<xml>", so we end up having three jaxb2 classes with @XmlRootElement(name="xml") which causes a problem when the information is marshalled. The marshaller fails because it can't figure out which <xml>-structure is coming.

    We are using Http message converters with a jaxb2 marshaller set up like this:
    	<beans:bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    	    <beans:property name="classesToBeBound">
    This is how the web service call is made:
        	String url = ConstantHelper.MY_URI_BASE + ConstantHelper.MY_PLACES_URL + urlParameters;
        	EventXml eventList = restTemplate.getForObject(url, EventXml.class);
    The preferred solution would of course be to solve the issue at the root and deliver xml with different tag names or have them qualified with name spaces, but there is now way we can have any changes made there.

    So can someone please suggest a good way to solve this?
    Last edited by weedobooty; Apr 30th, 2012, 04:27 AM. Reason: Added code snippet