I need to consume a WebService that outputs XML. In code snippet below:
- getResult method can return XML with HTML tags (like <p> tag).
- So I'll have to manually transform the XML first before parsing it.
- But RestTemplate works fine with other calls. So I don't want to discard it & write manual logic everywhere.
Question:
- Is there a built-in way to get back raw xml as string using RestTemplate?
- Do I have to write a custom converter? Any pointers?
Following is my code :
@Rest(rootUrl = "http://my.root.url", converters ={SimpleXmlHttpMessageConverter.class })
public interface MyRestClient {
@Get("/path/to/restmethod/{day}")
MyResponse getResult(int day); <-------------- Returns null when return type is changed to String
}
I tried setting return type to String. But it returns null with this error: Failed to convert value of type 'null' to required type 'java.lang.String'
.