Monday, December 02, 2013

Parse SOAP Message Using PL/SQL

Suppose we want to parse bellow SOAP message :

   
   
      
         SOAP-ENV:Client
         The security token could not be authenticated or authorized; nested exception is org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized
      
   


To parse this SOAP we can write script like :
CREATE TABLE XMLMESSAGE(

  message XMLTYPE

  serial  number,
)


--before running bellow script insert the message in previously created table

select atts.faultcode,atts.faultstring 

   from XMLMESSAGE,
        xmltable(xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as
                               "SOAP-ENV"
                       
                           ),
                 '/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault'
                 passing XMLMESSAGE.MESSAGE columns 
                 faultcode varchar2(1000) path ''faultcode',
                 faultstring varchar2(1000) path ''faultstring'
                 ) atts where serial = 1;