在发布时不要用localhost+端口发布,发布时获取下服务器的IP地址
InetAddress address = null; try { address = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); } String hostAddress = address.getHostAddress(); Endpoint.publish("http://"+hostAddress+":8089/test", new WebService()); System.out.println("发布成功!");