Jun 21st, 2010, 03:43 AM
RESTTemplate: Programatically add/remove schema reference to control validation?
I'm using the RestTemplate class to consume a rest web service which unmarshalls XML into Java objects using JAXB - the default strategy I believe.
I'd like to configure the unmarshalling so that in production the XML is not validated against a schema but in test schema validation is used. Ideally I'd like this configuration to come from a properties file or similar. This means I need a programmatic switch in my code to set validation on/off after referencing the properties file.
I can see that Jaxb2Marshaller has a setSchema property. I can point this to a schema to switch on validation from my spring config xml file. But I can't see how I could do this from within my code. I can't seem to find a reference to the marshaller/unmarshaller from the RestTemplate that I could hook into.
Can anyone give me a pointer to how I could set the schema validation on/off from within code?
Tags for this Thread