【发布时间】:2016-02-15 21:34:20
【问题描述】:
谁能告诉我为什么会出现这个解析错误? XML 对我来说看起来不错。 SAXException=XML document structures must start and end within the same entity. 失败了
在这一行:
Document doc = builder.parse(inputSource); //fails here
代码如下:
String soapIn = "<?xml version='1.0' encoding='UTF-8' ?>\n" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:vid=\"http://videocontrollerchannelmap.queryservice.vcwh.oss.my.company.com/\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <vid:getInneoquestChannelMap>\n" +
" <appkey>ONE_CONTROLLER</appkey>\n" +
" <forceUpdate>true</forceUpdate>\n" +
" </vid:getInneoquestChannelMap>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
SOAPMessage newMsg = null;
try {
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(soapIn));
Document doc = builder.parse(inputSource); //fails here
DOMSource domSource = new DOMSource(doc);
【问题讨论】:
标签: java soap xml-parsing