Search code examples
javaxmlweb-servicessoapnusoap

Reserved Word Error XML


I have this SOAP Request that simply checks the balance of an account.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:tns="urn:someurn">
<SOAP-ENV:Body>
<Execute xmlns="">
<sessionId xmlns="">SomeSessionID</sessionId>
<username xmlns="">SomeUserName</username>
<password xmlns="">SomePassword</password>
<command xmlns="">CommandName</command>
<data xmlns=""><?xml version="1.0"?><meta><accountNo></accountNo></meta>   
</data>
</Execute>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Whenever I make the request this error occurs, I have read some stack questions regarding this that I need to clear that whitespaces I've already done that, I've also tried using html entities for the question marks still no avail.

The error is :XML error parsing SOAP payload on line 14: Reserved XML Name which is the data tag.

Anyone can help me here? Also, I'm using Java to make the Requests to the the server.


Solution

  • Line 14 is

    <data xmlns=""><?xml version="1.0"?><meta><accountNo></accountNo></meta>   
    

    You cannot have an xml header (the <?xml...?> tag) anywhere in the XML except as the first line. You must encode everything inside the <data>...</data> using entities, as in:

    <data xmlns="">&lt;?xml version="1.0"?&gt;&lt;meta&gt; ...