all,I have a question:
TextView resultText = (TextView) findViewById(R.id.result);
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(new MediaType("application", "xml"));
HttpEntity<Doctor> requestEntity = new HttpEntity<Doctor>(
requestHeaders);
String url = "http://192.168.1.102:8080/clinic/services/common/doctor/1";
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Doctor> responseEntity = restTemplate.exchange(url,
HttpMethod.GET, requestEntity, Doctor.class);
Doctor result = responseEntity.getBody();
resultText.setText(result.toString());
when I run Android project throws RestClientException,follow:
org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [spring.domain.Doctor] and content type [application/xml]
How can I create a HttMessageCoonverter for xml data?
Thanks a lot!
There is some documentation on Spring Android regarding Rest Templates. Without seeing your Spring configuration setup, it is hard to determine the issue, but I would definitely start there.
The documentation suggests that Spring Android supports the Simple XML Serializer library by default. Perhaps if you add that library to your classpath it will ‘just work’.