繁体   English   中英

java.net.ConnectException:连接超时:在Eclipse中连接

[英]java.net.ConnectException: Connection timed out: connect in Eclipse

我正在尝试使用Eclipse在公共Web服务以下进行消费。 http://www.webservicex.com/globalweather.asmx?wsdl

当我在Java客户端中执行时,会出现错误;

java.net.ConnectException: Connection timed out: connect

下面是简单的客户端程序;

public class ClientTest1 
{
    public static void main(String[] args) 
    {
        GlobalWeatherSoapProxy obj1 = new GlobalWeatherSoapProxy();
        try
        {
            System.out.println(obj1.getCitiesByCountry("Japan"));
        }
        catch(Exception e1)
        {
            System.out.println(+e1.getMessage());
        }
    }
}

但是奇怪的是,当通过SOAP UI使用时,这可以正常工作。 因此,我认为这与Eclipse配置有关。

预先感谢您的任何帮助。

Eclipse与它无关。 即使您的开发环境是Eclipse,您的代码也会由JVM执行。 连接超时意味着您的客户端无法与端点连接。

您已通过某种方式自动生成了客户端代理,从而获取了GlobalWeatherSoapProxy 此类将通过加载WSDL获得对端点的引用。 或者,可以通过代码提供url。 查看该类的内容,以了解如何加载端点URL

您应该看到类似的内容(请查看此完整示例

URL url = new URL("http://localhost:9999/ws/hello?wsdl");
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM