我是 web 服务的新手,并试图使用 RestTemplate 编写一个 RESTFul web 服务的客户端。我使用 org.springframework.http.converter.xml.MarshallingHttpMessageConverter 作为消息转换器,使用 org.springframework.oxm.xstream.XStreamMarshaller 作为编组器。
有没有办法进一步调试或找出这个问题的根本原因?
我的消费类是这样的——
@SuppressWarnings("unchecked")
public List<Deal> getClientInformation() throws RestClientException {
return restTemplate.getForObject(webServiceURL, List.class);
}
例外 :
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error: Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:177)
at main.java.com.sample.consumer.DealConsumer.getClientInformation(Consumer.java:35)
at main.java.com.client.WebserviceConsumerTestClient.main(WebserviceConsumerTestClient.java:16)
引起:java.net.ConnectException:连接被拒绝:连接在 org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)