當我創建Document對象時,遇到文件錯誤的提前結束。這段代碼在幾天前工作,我不確定是什麼導致它現在拋出一個錯誤。構建DOM文檔對象時文件錯誤的提前結束
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(response));
Document doc = builder.parse(is);
[致命錯誤】:1:1:文件過早結束。
這是我收到的響應xml。它看起來非常好。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetBatchFilesResponse xmlns="http://....">
<GetBatchFilesResult>
<BatchFile>
<Uri>someURI</Uri>
<ID>2025961</ID>
<FQName>someFileName</FQName>
</BatchFile>
</GetBatchFilesResult>
</GetBatchFilesResponse>
</soap:Body>
</soap:Envelope>
從那以後XML內容是否改變了?因爲錯誤消息提示它具有... – ppeterka 2013-03-19 16:11:12
問題更可能出現在「響應」變量中。 – benzonico 2013-03-19 16:11:40
我已將我的xml響應添加到您要查看的問題中。 – zms6445 2013-03-19 17:46:09