您必须创建自己的URLStreamHandler,以便可以设置URLConnection参数,例如连接超时和读取超时。
SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();URL endpoint = new URL(new URL("http://yourserver.yourdomain.com/"), "/path/to/webservice", new URLStreamHandler() { @Override protected URLConnection openConnection(URL url) throws IOException { URL target = new URL(url.toString()); URLConnection connection = target.openConnection(); // Connection settings connection.setConnectTimeout(10000); // 10 sec connection.setReadTimeout(60000); // 1 min return(connection); } });SOAPMessage result = connection.call(soapMessage, endpoint);为了清楚起见,我删除了一些try / catch。



