布尔返回类型不适用于 RestTemplate
我正在使用 Spring 3.0.3 RestTemplate 对部署在 servicemix ESB 中的服务进行 RESTfull 调用。服务方法返回布尔值,并且无法在 RestTemplate 响应中接收该值。
String query = "?userId="+userId;
RestTemplate rest = new RestTemplate();
Map<String, String> params = new HashMap<String, String>();
boolean status = rest.getForObject(SERVICE_URL+query,boolean.class,params);
我遇到以下错误
WARN : org.springframework.web.client.RestTemplate - GET request for "http://localhost:818 1/cxf/monitoring/logclear?userId=admin" resulted in 406 (Not Acceptable); invoking error handler org.springframework.web.client.HttpClientErrorException: 406 Not Acceptable at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultR esponseErrorHandler.java:69) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:206)
非常感谢任何帮助。谢谢你!
I am using Spring 3.0.3 RestTemplate for making RESTfull call to service which is deployed in servicemix ESB. Service method returns boolean value, and am unable to receive this in RestTemplate response.
String query = "?userId="+userId;
RestTemplate rest = new RestTemplate();
Map<String, String> params = new HashMap<String, String>();
boolean status = rest.getForObject(SERVICE_URL+query,boolean.class,params);
And am getting below error
WARN : org.springframework.web.client.RestTemplate - GET request for "http://localhost:818 1/cxf/monitoring/logclear?userId=admin" resulted in 406 (Not Acceptable); invoking error handler org.springframework.web.client.HttpClientErrorException: 406 Not Acceptable at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultR esponseErrorHandler.java:69) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:206)
Any help is greatly appreciated. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论