1

波浪号是 XML SOAP 消息中的合法字符吗?我得到一个 SAXParseException:Content not allowed in prolog。我包含了大部分 SOAP 消息,以防万一我找错了树。

POST /... HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: 127.0.0.1:1234
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 1497
Authorization: Basic b3BlbnBkbTpvdHRvMTIz

<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
         <ns1:query soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://localhost">
            <where xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">type ~~ 'command'</where>

         </ns1:query>
      </soapenv:Body>
   </soapenv:Envelope>
4

2 回答 2

2

我不确定 SOAP 消息,但在处理 XML 文件时,此错误消息的另一个可能原因是文件开头是否有BOM(字节顺序标记) - 如果某些 XML 解析器无法处理未正确配置或调用。检查(使用十六进制编辑器)并尝试删除它会发生什么。

例如,在 Python 中,有必要打开一个 UTF-8 编码的 XML 文件,codecs.open(filename, "UTF-8")而不仅仅是open(filename)确保 BOM(如果存在)得到正确处理。

于 2008-11-21T20:44:57.907 回答
1

波浪号是 XML SOAP 消息中的合法字符吗?

是的。错误消息指向另一个错误源(“序言”)。HTTP 标头是否可能是发送到 SAX 解析器的代码的一部分,就像在您的代码示例中一样?

于 2008-11-21T20:18:16.633 回答