Java org.xml.sax.SAXException:SimpleDeserializer遇到子元素,这不是预期的

Java org.xml.sax.SAXException:SimpleDeserializer遇到子元素,这不是预期的,java,xml,web-services,soap,sax,Java,Xml,Web Services,Soap,Sax,我有以下文件,我cURL: <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org

我有以下文件,我
cURL

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <ProcessMessage xmlns="http://www.user.com/test/">
        <envelope>Encoded XML request message will go here</envelope>
      </ProcessMessage>
   </soap:Body>
</soap:Envelope>
当我使用带有
CDATA
元素的文件时,一切都正常工作

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <ProcessMessage xmlns="http://www.user.com/test/">
         <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
           <envelope>Encoded XML request message will go here</envelope>
         ]]>
      </ProcessMessage>
   </soap:Body>
</soap:Envelope>

编码的XML请求消息将显示在此处
]]>
你知道我如何在没有CDATA部分的情况下接受XML文件吗?

引用:“格式良好的XML中只允许有一个XML声明,如果在任何地方,它必须位于顶部。”

见:


因此,如果你能摆脱第二个
你就可以了。

问题不在于

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <ProcessMessage xmlns="http://www.user.com/test/">
         <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
           <envelope>Encoded XML request message will go here</envelope>
         ]]>
      </ProcessMessage>
   </soap:Body>
</soap:Envelope>