为什么connection.getResponseCode会抛IOException
下面是我的代码,testURL是另外一台机器,我在我的机器上call那个webservice的时候,会抛IOException,请高手指教问题出在哪里?String testURL = "http://10.70.3.181:8080/test/wservices/mytest?wsdl";
URL url = new URL (testURL);
HttpURLConnection connection = (HttpURLConnection)url.openConnection ();
int state = connection.getResponseCode (); --------------------编程问答-------------------- IOException - if an error occurred connecting to the server.
--------------------编程问答-------------------- 首先在浏览器直接打开http://10.70.3.181:8080/test/wservices/mytest?wsdl,这个链接看看行不行?
HttpURLConnection connection = (HttpURLConnection)url.openConnection (); // 打开连接
这行加一句:connection.connect(); // 进行连接。。。
int state = connection.getResponseCode (); // 响应结果状态 --------------------编程问答-------------------- 可能是500,看具体异常信息
补充:Java , Web 开发