views:

514

answers:

2
+1  Q: 

tilde in XML

Is tilde a legitimate character in an XML SOAP message? I get a SAXParseException:Content not allowed in prolog. I included most of the SOAP message just in case I'm barking up the wrong tree.

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"&gt;
      <soapenv:Body>
         <ns1:query soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://localhost"&gt;
            <where xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;type ~~ 'command'</where>

         </ns1:query>
      </soapenv:Body>
   </soapenv:Envelope>
+1  A: 

Is tilde a legitimate character in an XML SOAP message?

Yes. The error message points to another error source (“prolog”). Is the HTTP header perhaps part of the code sent to the SAX parser, as in your code sample?

Konrad Rudolph
+2  A: 

I'm not sure about SOAP messages, but when processing XML files, one other possible reason for this error message is if there is a BOM (byte order marker) at the beginning of the file - some XML parsers can't handle that if not configured or invoked correctly. Check for that (using a hex editor) and try what happens if you remove it.

In Python, for example, it is necessary to open an UTF-8 encoded XML file using codecs.open(filename, "UTF-8") instead of just open(filename) to make sure a BOM, if present, is handled correctly.

Tim Pietzcker