2

I have the following xml value which is stored in the request_xml column and which is clob data type:

  <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns:updateRechargeTicketResponse xmlns:ns="http://service.soap.CDRator.com">
      <ns:return xmlns:ax232="http://core.result.service.soap.CDRator.com/xsd" xmlns:ax233="http://core.data.soap.CDRator.com/xsd" xmlns:ax230="http://payment.result.service.soap.CDRator.com/xsd" xmlns:ax228="http://data.soap.CDRator.com/xsd" xmlns:ax231="http://result.service.soap.CDRator.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax230:RechargeTicketResultDTO">
        <ax233:id xsi:nil="true"/>
        <ax232:code>0</ax232:code>
        <ax232:description>SOAP_GLOBAL_SUCCESS</ax232:description>
        <ax232:serviceUser xsi:nil="true"/>
        <ax232:success>true</ax232:success>
        <ax232:translationTag>SOAP_GLOBAL_SUCCESS</ax232:translationTag>
        <ax230:rechargeTicket xsi:type="ax228:RechargeTicketDTO">
          <ax233:id>201505131421267777</ax233:id>
          <ax233:billingGroupId>201505071857272816</ax233:billingGroupId>
          <ax233:code>BALANCE_DIRECTDEBIT</ax233:code>
          <ax233:dateCreated>2015-05-13</ax233:dateCreated>
          <ax233:dayOfMonth>0</ax233:dayOfMonth>
          <ax233:nextRechargeDate xsi:nil="true"/>
          <ax233:rechargeAmount>10.0</ax233:rechargeAmount>
        </ax230:rechargeTicket>
      </ns:return>
    </ns:updateRechargeTicketResponse>
  </soapenv:Body>
</soapenv:Envelope>

I want to extract the value from . I have used the below query but it returns nothing.I am getting an error as

ORA-19228: XPST0008 - undeclared identifier: prefix 'ax230' local-name 'ax230:rechargeTicket'
19228. 00000 -  "XPST0008 - undeclared identifier: prefix '%s' local-name '%s'"

Here is my query

   SELECT ID,CREATE_DATE,WEB_SERVICE_NAME,WEB_METHOD_NAME,xt_billingGroupId.BILLING_GROUP_ID,xt_error_code.ERROR_CODE,xt_error_message.ERROR_DESCRIPTION,xt_code.CODE,xt_rec_id.RECHARGE_TICKET_ID
FROM TEMP_SOAP_MONITORING_TOPUP sm
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://schemas.xmlsoap.org/soap/envelope/' AS "soapenv",
      'http://service.soap.CDRator.com' as "ns",
      'http://core.data.soap.CDRator.com/xsd' as "ax2130",
      'http://webshop.result.service.soap.CDRator.com/xsd' as "ax2147",
      'http://core.signup.data.soap.CDRator.com/xsd' as "ns3",
      'http://service.soap.CDRator.com' as "ns5",      
      'http://core.data.soap.CDRator.com/xsd' as "ax233",
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //*:billingGroupId return $i'
    passing XMLType(sm.REQUEST_XML)
    columns "BILLING_GROUP_ID" VARCHAR2(100) path '/') xt_billingGroupId    
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //ax232:code return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "ERROR_CODE" VARCHAR2(100) path '/') xt_error_code 
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //ax232:description return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "ERROR_DESCRIPTION" VARCHAR2(200) path '/') xt_error_message
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //*:code return $i'
    passing XMLType(sm.REQUEST_XML)
    columns "CODE" VARCHAR2(100) path '/') xt_code
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.data.soap.CDRator.com/xsd' as "ax233"
    ),
    'for $i in //ax230:rechargeTicket  return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "RECHARGE_TICKET_ID" VARCHAR2(200) path 'ax233:id') xt_rec_id

1 Answer 1

2

Your namespaces don't match on your source XML and your query

'http://data.soap.CDRator.com/xsd' as "ax233"

vs

xmlns:ax233="http://core.data.soap.CDRator.com/xsd"

Try either removing core. from your source or adding core. to your XMLNAMESPACES for ax233.


To fix the error:

ORA-19228: XPST0008 - undeclared identifier: prefix 'ax230' local-name 'ax230:rechargeTicket'
19228. 00000 -  "XPST0008 - undeclared identifier: prefix '%s' local-name '%s'"

you are missing namespace declaration for ax230 so to XMLNAMESPACES you need to add:

'http://payment.result.service.soap.CDRator.com/xsd' as "ax230",

You might also find it easier if the query is formatted nicer (unless you have a reason you are doing it the way you are). For a sample, see below:

SELECT 
  t.error_code
, t.error_description
, t.code
FROM temp_soap_monitoring_topup sm
, XMLTABLE(
    XMLNAMESPACES (
      'http://schemas.xmlsoap.org/soap/envelope/' AS "soapenv",
      'http://service.soap.CDRator.com' as "ns",
      'http://core.data.soap.CDRator.com/xsd' as "ax2130",
      'http://webshop.result.service.soap.CDRator.com/xsd' as "ax2147",
      'http://core.signup.data.soap.CDRator.com/xsd' as "ns3",
      'http://service.soap.CDRator.com' as "ns5",
      'http://payment.result.service.soap.CDRator.com/xsd' as "ax230",      
      'http://core.data.soap.CDRator.com/xsd' as "ax233",
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    )
  , 'soapenv:Envelope/soapenv:Body/ns:updateRechargeTicketResponse/ns:return'
  PASSING XMLTYPE(sm.response_xml)
  COLUMNS
    error_code        VARCHAR2(100) PATH 'ax232:code/text()'
  , error_description VARCHAR2(100) PATH 'ax232:description/text()'
  , code              VARCHAR2(100) PATH 'ax230:rechargeTicket/ax233:code/text()'
  ) t
Sign up to request clarification or add additional context in comments.

4 Comments

I've put your XML in a table in my local DB, replaced 'http://data.soap.CDRator.com/xsd' as "ax233", with 'http://core.data.soap.CDRator.com/xsd' as "ax233", and I am getting the ID back
Hello i have edited my question it works fine when i tested it with only this condition but now i have mentined my complete query and it gives an error. Can you please tell me the why its giving an error ? Please just look at my last cross join in query where i am having an error.
See my edit - you are now missing ax230 namespace in your query
Edited again having done a brief tidy up. You can do this in 2 XMLTables, one for request_xml and one for response_xml. Build your path appropriately and then select multiple columns following a simple relative path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.