2

I parsed a SOAP response. Next I want to check the value of <HasError> like so:

DECLARE
l_clob CLOB;
l_error VARCHAR2(20);
BEGIN
--SOAP RESPONSE
l_clob :=
'
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <GSFRR xmlns="http://tst.com/">
         <GSFRRe>
            <Error>Error on GSFRConnector.</Error>
            <HasError>true</HasError>
            <IsSuccess>false</IsSuccess>
         </GSFRRe>
      </GSFRR>
   </soap:Body>
</soap:Envelope>
';

--GET VALUE FOR HasError
SELECT HasError INTO l_error FROM xmltable(
    xmlnamespaces('http://www.w3.org/2003/05/soap-envelope' as "soap",default 'http://www.w3.org/2003/05/soap-envelope'),
    '/soap:Envelope/soap:Body/GSFRR/GSFRRe'
    passing xmlparse(document l_clob)
    columns haserror varchar2(20) path 'HasError');   
END;

However, when I try this I get the following error(s):

ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00209: PI names starting with XML are reserved

This is my first time working with SOAP. I'm at my wits end. Can anyone point out where I go wrong please?

I use Oracle 19.2.

kjhughes
  • 106,133
  • 27
  • 181
  • 240

1 Answers1

4

Change

'
<?xml version="1.0" encoding="UTF-8"?>

to

'<?xml version="1.0" encoding="UTF-8"?>

because there can be no characters, even whitespace, before the XML declaration.

See also Error: The processing instruction target matching "[xX][mM][lL]" is not allowed

kjhughes
  • 106,133
  • 27
  • 181
  • 240