部分代码如下:
public class DomXMLString {
private static String SERVICES_HOST = "www.webxml.com.cn";
private static String NETDATA_URL = "http://183.131.242.70:8089/ship/interface/shipInfoService.asmx/getTask";
private static String LOCAL_PC_SAVEFILE_URL = "E:Myeclipse/sy_Task.xml";
private DomXMLString(){}
public static void main(String[] args)throws Exception {
Document document = getTask(NETDATA_URL);
helloOK(document,LOCAL_PC_SAVEFILE_URL);
}
private static Document getTask(String netXMLDataURL) {
Document document = null;
DocumentBuilderFactory documentBF = DocumentBuilderFactory.newInstance();
documentBF.setNamespaceAware(true);
try{
DocumentBuilder documentB = documentBF.newDocumentBuilder();
InputStream inputStream = getSoapInputStream(netXMLDataURL);
document = documentB.parse(inputStream);
inputStream.close();
}catch(DOMException e){
e.printStackTrace();
return null;
}catch(ParserConfigurationException e){
e.printStackTrace();
return null;
}catch(SAXException e){
e.printStackTrace();
return null;
}catch(IOException e){
e.printStackTrace();
return null;
}
return document;
}
运行提示错误为:
java.io.IOException: Server returned HTTP response code: 500 for URL: http://183.131.242.70:8089/ship/interface/shipInfoService.asmx/getTask
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
at org.tempuri.DomXMLString.getSoapInputStream(DomXMLString.java:79)
at org.tempuri.DomXMLString.getTask(DomXMLString.java:52)
at org.tempuri.DomXMLString.main(DomXMLString.java:39)
Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:117)
at org.tempuri.DomXMLString.getTask(DomXMLString.java:53)
at org.tempuri.DomXMLString.main(DomXMLString.java:39)
之前也查了一些资料,想请问是不是我设置的路径有问题以及解决办法,求大神指点迷津