2012-07-25 4 views
9

저는 webservices를 처음 사용하고 RestTemplate을 사용하여 RESTFul 웹 서비스의 클라이언트를 작성하려고합니다. org.springframework.http.converter.xml.MarshallingHttpMessageConverter를 메시지 변환기로 사용하고 org.springframework.oxm.xstream.XStreamMarshaller를 marshaller로 사용하고 있습니다.Spring RestTemplate 클라이언트 연결이 거부 된 예외

더 이상 디버깅하거나이 문제의 근본 원인을 알 수있는 방법이 있습니까? java.net.ConnectException :

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) 

에 의해 발생 : 연결이 거부 : org.springframework에서 를 연결

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

}

예외 -

내 소비자 클래스는 다음과 같습니다 .web.client.RestTemplate.doExecute (RestTemplate.java:359)

답변

16

호출하려는 webServiceURL에 연결할 수 없습니다. webServiceURL 경로가 올 바르고 들어 있는지 확인하십시오.

추신. 또한 서버 측에 방화벽 문제가 있는지 확인하십시오.

Wireshark가 더 디버깅하는 데 도움이 될 수 있습니다.

http://www.wireshark.org/

+3

방화벽 문제였습니다. 클라이언트 코드에서 웹 서비스를 시작하기 전에 두 줄을 추가하여이 오류를 해결할 수있었습니다. System.setProperty ("proxyHost", "yourproxy.server.com"); System.setProperty ("proxyPort", "8080"); – PST

+2

보다 낫지 만, 이제 문제가 해결되면 답변을 올바른 것으로 표시하여이 질문을 닫을 수 있습니다. – dhamibirendra

+0

@ dhamibirendra 고맙습니다. – pudaykiran

관련 문제