SAXException = XML文档结构必须在同一实体中开始和结束

时间:2016-02-15 21:34:21

标签: java soap xml-parsing

有人可以告诉我为什么我得到这个解析错误? 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);

1 个答案:

答案 0 :(得分:3)

您错过了>上的"</soapenv:Envelope"