clientEx.getResponseBodyAsByteArray();
OR
clientEx.getResponseBodyAsString();
But there is one special case, when error code is 40x, it fails to capture the response body.
Reason is described in ticket SPR-9999
While solution is quite simple as some one mentioned in the ticket. Use the "org.springframework.http.client.HttpComponentsClientHttpRequestFactory" instead of the default one.
So the configuration should be:
<bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"/> <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"> <property name="requestFactory" ref="clientHttpRequestFactory"/> </bean>
No comments:
Post a Comment