【问题标题】:SAXException=XML document structures must start and end within the same entitySAXException=XML 文档结构必须在同一个实体内开始和结束
【发布时间】: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


    【解决方案1】:

    您在"&lt;/soapenv:Envelope" 上缺少&gt;

    【讨论】:

    • 天哪。盯着它看太久了。谢谢!
    猜你喜欢
    • 2021-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多