I'm using spring RestTemplate for communication with a xml webservice backend as follows:
ResponseEntity<MainDTO> dto = restTemplate.postForObject(url, postData, MainDTO.class);
Problem: the backend might either respond with MainDTO for normal data or with ErrorDTO in case of failures. But both with HTTP 200.
But I don't know which object will come back before! Anyways restTemplate requires me to pass the class type before.
So, how could I parse the xml either to normal or the error bean?
Sidenote: I don't have any control of the webservice backend.