Reputation: 337
I'm consuming a http endpoint which is returns a text/xml content as the response. It should return a number as the response within xml document. How do I parse it.
Here is the response when I consume the endpoint using postman.
<?xml version="1.0" encoding="utf-8"?>
<int xmlns="http://tempuri.org/">2</int>
When I try as below, it gives me an error.
Integer originalResponse = REST_TEMPLATE.exchange(new URI(PropertyConfig.endPointUrl), HttpMethod.POST, httpEntity, Integer.class).getBody();
but if I set the return type as String, It gives me the xml as a plain text. I need get the number which is within the tags as the result.
Is there a way to do this?
Upvotes: 0
Views: 384