XML : Using XMLTABLE to parse CDATA section of SOAP

I'm following the example in this thread to learn how to parse the CDATA section of a SOAP response using XMLTABLE. Database is Oracle Database 11g Enterprise Edition 11.2.0.4.0.

I modified the SOAP response that I need to parse just so I could have a query that works, similar to the example I was looking at.

So this is what is working ok, albeit with a slightly simplified response envelope:

  CREATE TABLE xml_tab (xml_data xmltype);    DECLARE l  l_xmltype xmltype;    BEGIN    SELECT xmltype('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:sawsoap="urn://oracle.bi.webservices/v6">    <soap:Body>      <sawsoap:executeSQLQueryResult>        <sawsoap:return xsi:type="sawsoap:QueryResults">          <sawsoap:rowset><![CDATA[<Data><Row><Column0>1200</Column0><Column1>East Region</Column1></Row><Row><Column0>3000</Column0><Column1>West Region</Column1></Row></Data>]]></sawsoap:rowset>          <sawsoap:queryID/>          <sawsoap:finished>true</sawsoap:finished>        </sawsoap:return>      </sawsoap:executeSQLQueryResult>    </soap:Body>  </soap:Envelope>') INTO l_xmltype FROM dual ;    INSERT INTO xml_tab VALUES(l_xmltype);    END;    

And this query returns the results I want:

  SELECT B2.*       FROM      xml_tab x,     XMLTable(             XMLNamespaces(               'http://schemas.xmlsoap.org/soap/envelope/' AS "SOAP-ENV"                ,'urn://oracle.bi.webservices/v6' AS  "sawsoap"                            )            , 'SOAP-ENV:Envelope/SOAP-ENV:Body/sawsoap:executeSQLQueryResult/sawsoap:return/sawsoap:rowset'              passing    x.XML_DATA             columns Row1 clob path '.'           ) A1,          XMLTable(             '/Data/Row'             passing xmlparse(document A1.Row1)             columns               Amount number PATH 'Column0',           Region varchar2(60) PATH 'Column1'         ) B2;        AMOUNT REGION                                                         ---------- ------------------------------------------------------------    1200 East Region                                                      3000 West Region     

Unfortunately the actual SOAP response that I need to parse looks like this:

  truncate table xml_tab;     DECLARE    l_xmltype xmltype;  BEGIN    SELECT xmltype('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:sawsoap="urn://oracle.bi.webservices/v6">    <soap:Body>      <sawsoap:executeSQLQueryResult>        <sawsoap:return xsi:type="sawsoap:QueryResults">          <sawsoap:rowset><![CDATA[<rowset xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" ><Row><Column0>01200/Column0><Column1>East Region</Column1></Row><Row><Column0>3000</Column0><Column1>West Region</Column1></Row></rowset>]]></sawsoap:rowset>          <sawsoap:queryID/>          <sawsoap:finished>true</sawsoap:finished>        </sawsoap:return>      </sawsoap:executeSQLQueryResult>    </soap:Body>  </soap:Envelope>')    INTO l_xmltype    FROM dual ;    INSERT INTO xml_tab VALUES      (l_xmltype      );  END;    

Because of this bit, rowset xmlns="urn:schemas-microsoft-com:xml-analysis:rowset", my code no longer works and I don't know how to get past this. If anyone can suggest modifications to my query that will successfully parse this SOAP response I would greatly appreciate the help.

No comments:

Post a Comment