saranya
saranya

Reputation: 55

Spring Boot - webservice: Connection Refused

I am trying to implement spring boot webservice application as given in spring docs :

https://spring.io/guides/gs/consuming-web-service/

Build was successful, request and response java files was created and , but when executed spring-boot:run , it gives

Caused by: org.springframework.ws.client.WebServiceIOException: I/O error: Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
    at hello.WeatherClient.getCityForecastByZip(WeatherClient.java:30)
    at hello.Application.main(Application.java:20)

But the URL is accessible via web browser in eclipse. Kindly help me solve this issue

Upvotes: 2

Views: 29262

Answers (2)

Dmitry Trifonov
Dmitry Trifonov

Reputation: 1119

Make sure all your tests declared with same @SpringBootTest annotation parameters. I had same issue because of different parameters in two tests. Problem gone when I made all annotations same: @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT))

Upvotes: 1

Hemant Metalia
Hemant Metalia

Reputation: 30638

The web Service URL you are trying to call may be not reachable or it gets timeout. Ensure the web Service URL path is correct and is listening. also verify the timeout duration set and the time taken from your request.

PS. Also check if there is some firewall issue at Server side.

For firewall issue, you might need to provide proxy details(proxyHost and proxyPort) In client code.

EDIT:

I am not able to find appropriate blog or something which explains it better. but found one question on stackoverflow which has similar answer : here

Upvotes: 0

Related Questions