Hello.
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:
This is how the web service call is made:Code:<beans:bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <beans:property name="classesToBeBound"> <beans:list> <beans:value>com.mycompany.mysystem.model.jaxb.Member</beans:value> <beans:value>com.mycompany.mysystem.model.jaxb.Xml</beans:value> <beans:value>com.mycompany.mysystem.model.jaxb.Gpx</beans:value> <beans:value>com.mycompany.mysystem.model.jaxb.EventXml</beans:value> <beans:value>com.mycompany.mysystem.model.User</beans:value> </beans:list> </beans:property> </beans:bean>
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.Code:String url = ConstantHelper.MY_URI_BASE + ConstantHelper.MY_PLACES_URL + urlParameters; EventXml eventList = restTemplate.getForObject(url, EventXml.class);
So can someone please suggest a good way to solve this?


Reply With Quote