无法在Eclipse中从客户端或从restclient-ui使用外部RestFul Web服务

时间:2015-06-17 07:30:05

标签: java eclipse web-services restful-url rest-client

我无法从客户端使用RESTful Web服务。我在eclipse中编写过,甚至无法从restclient-ui中使用它,但可以访问在我的位置Web逻辑服务器中运行的示例RESTful Web服务。我在公司/公司网络。获取错误连接超时异常。

来自restclient-ui的错误为

Connection to http://api.openweathermap.org refused
org.apache.http.conn.HttpHostConnectException: Connection to http://api.openweathermap.org refused
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at org.wiztools.restclient.HTTPClientRequestExecuter.execute(HTTPClientRequestExecuter.java:303)
    at org.wiztools.restclient.ui.RESTView$26.run(RESTView.java:1061)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:123)
    ... 7 more

1 个答案:

答案 0 :(得分:2)

尝试使用以下方式设置公司的代理:

System.getProperties().put("https.proxyHost", "proxyHost");
System.getProperties().put("https.proxyPort", "proxyPort");

同样适用于http。