相关疑难解决方法(0)

Spring RestTemplate Client - 连接拒绝异常

我是webservices的新手,并尝试使用RestTemplate编写RESTFul webservice的客户端.我使用org.springframework.http.converter.xml.MarshallingHttpMessageConverter作为消息转换器,org.springframework.oxm.xstream.XStreamMarshaller作为marshaller.

有没有办法进一步调试这个或找出这个问题的根本原因?

我的消费者类看起来像这样 -

@SuppressWarnings("unchecked")
public List<Deal> getClientInformation() throws RestClientException {
    return restTemplate.getForObject(webServiceURL, List.class);
Run Code Online (Sandbox Code Playgroud)

}

例外:

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)
Run Code Online (Sandbox Code Playgroud)

引起:java.net.ConnectException:连接被拒绝:连接org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)

rest spring client web-services

11
推荐指数
1
解决办法
7万
查看次数

标签 统计

client ×1

rest ×1

spring ×1

web-services ×1