我在测试Java Web Service时遇到此错误。这是我使用import DocumentException的例外:
Element root = null;
SAXReader reader = new SAXReader();
Document document;
try {
document = reader.read(new java.io.StringReader(outputXml));
} catch (DocumentException e) {
Output.setErrorCode("100");
Output.setErrorText("Greska " + e);
return Output;
}
我对发生的事情一无所知..提前致谢。
更新
String outputXml = getHTML(poziv);
private String getHTML(String urlToRead) {
URL url;
HttpURLConnection conn;
BufferedReader rd;
String line;
String result = "";
try {
url = new URL(urlToRead);
conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/xml");
rd =
new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = rd.readLine()) != null) {
result += line;
}
rd.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
另外,我有一个基本的web.xml,但不确定它是否与错误有关。