I am consuming a webservice which is returning the xsd schema as response,below is the request and response details
Request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://track.smsaexpress.com/secom/">
<soapenv:Header/>
<soapenv:Body>
<sec:getShipUpdates>
<sec:rowId> 504634558</sec:rowId>
<!--Optional:-->
<sec:passKey>TestingkeyExample</sec:passKey>
</sec:getShipUpdates>
</soapenv:Body>
</soapenv:Envelope>
Response
<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">
<soap:Body>
<getShipUpdatesResponse xmlns="http://track.smsaexpress.com/secom/">
<getShipUpdatesResult>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Tracking">
<xs:complexType>
<xs:sequence>
<xs:element name="rowId" type="xs:long" minOccurs="0"/>
<xs:element name="awbNo" type="xs:string" minOccurs="0"/>
<xs:element name="Date" type="xs:string" minOccurs="0"/>
<xs:element name="Activity" type="xs:string" minOccurs="0"/>
<xs:element name="Details" type="xs:string" minOccurs="0"/>
<xs:element name="Location" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Tracking diffgr:id="Tracking1" msdata:rowOrder="0">
<rowId>99438814</rowId>
<awbNo>290012097109</awbNo>
<Date>12 Nov 2017 15:47</Date>
<Activity>DATA RECEIVED</Activity>
<Details>Online Data Submitted</Details>
<Location>Riyadh</Location>
</Tracking>
<Tracking diffgr:id="Tracking2" msdata:rowOrder="1">
<rowId>99438812</rowId>
<awbNo>290012097092</awbNo>
<Date>12 Nov 2017 15:47</Date>
<Activity>DATA RECEIVED</Activity>
<Details>Online Data Submitted</Details>
<Location>Riyadh</Location>
</Tracking>
</NewDataSet>
</diffgr:diffgram>
</getShipUpdatesResult>
</getShipUpdatesResponse>
</soap:Body>
</soap:Envelope>
Code :
create or replace function getSamsaShipUpdates(p_row_id NUMBER,p_key_flg varchar2) return varchar2 IS
l_status VARCHAR2(4000) DEFAULT NULL;
l_xml XMLTYPE;
begin
l_envelope := '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://track.smsaexpress.com/secom/">
<soapenv:Header/>
<soapenv:Body>
<sec:getShipUpdates>
<sec:rowId>'||p_row_id||'</sec:rowId>
<!--Optional:-->
<sec:passKey>'||p_key_flg||'</sec:passKey>
</sec:getShipUpdates>
</soapenv:Body>
</soapenv:Envelope>';
l_xml := APEX_WEB_SERVICE.make_request(
p_url => 'http://track.smsaexpress.com/SECOM/SMSAwebServiceIntl.asmx',
p_action => 'http://track.smsaexpress.com/secom/SMSAWebserviceIntl/getShipUpdates',
p_envelope => l_envelope
);
l_status := APEX_WEB_SERVICE.parse_xml(
p_xml => l_xml,
p_xpath => '//text()',
p_ns => 'xmlns="http://track.smsaexpress.com/secom/SMSAWebserviceIntl"'
);
end getSamsaShipUpdates;
The above code i am trying to get response into Varchar variable however the response is more than 4000 records as this is a data set . Please provide any example how exactly we can parse the response into a table or can be looped through.
Update
I have tried by putting response into CLOB variable however i am getting empty response while running the code
Below is the code
DECLARE
v_xml CLOB;
BEGIN
v_xml :=
'<?xml version="1.0" encoding="utf-8"?>
<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">
<soap:Body>
<getTrackingResponse xmlns="http://track.smsaexpress.com/secom/SMSAWebserviceIntl">
<getTrackingResult>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Tracking">
<xs:complexType>
<xs:sequence>
<xs:element name="awbno" type="xs:string" minOccurs="0" />
<xs:element name="Date" type="xs:string" minOccurs="0" />
<xs:element name="Activity" type="xs:string" minOccurs="0" />
<xs:element name="Details" type="xs:string" minOccurs="0" />
<xs:element name="Location" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Tracking diffgr:id="Tracking1" msdata:rowOrder="0">
<awbno>290340366704</awbno>
<Date>19 Sep 2022 13:12</Date>
<Activity>PROOF OF DELIVERY CAPTURED</Activity>
<Details>Received By :: zainb at Sep 19 2022 1:12PM</Details>
<Location>Dammam</Location>
</Tracking>
<Tracking diffgr:id="Tracking2" msdata:rowOrder="1">
<awbno>290340366704</awbno>
<Date>19 Sep 2022 09:12</Date>
<Activity>OUT FOR DELIVERY</Activity>
<Details>Dammam</Details>
<Location>Dammam</Location>
</Tracking>
<Tracking diffgr:id="Tracking3" msdata:rowOrder="2">
<awbno>290340366704</awbno>
<Date>18 Sep 2022 22:34</Date>
<Activity>DEPARTED HUB FACILITY</Activity>
<Details>Dammam</Details>
<Location>Dammam</Location>
</Tracking>
<Tracking diffgr:id="Tracking4" msdata:rowOrder="3">
<awbno>290340366704</awbno>
<Date>18 Sep 2022 22:30</Date>
<Activity>ARRIVED HUB FACILITY</Activity>
<Details>Dammam</Details>
<Location>Dammam</Location>
</Tracking>
<Tracking diffgr:id="Tracking5" msdata:rowOrder="4">
<awbno>290340366704</awbno>
<Date>18 Sep 2022 18:58</Date>
<Activity>DEPARTED FORM ORIGIN</Activity>
<Details>Dammam</Details>
<Location>Dammam</Location>
</Tracking>
<Tracking diffgr:id="Tracking6" msdata:rowOrder="5">
<awbno>290340366704</awbno>
<Date>18 Sep 2022 16:41</Date>
<Activity>COLLECTED FROM RETAIL</Activity>
<Details>Dammam</Details>
<Location>Dammam</Location>
</Tracking>
<Tracking diffgr:id="Tracking7" msdata:rowOrder="6">
<awbno>290340366704</awbno>
<Date>18 Sep 2022 15:09</Date>
<Activity>PICKED UP</Activity>
<Details>Dhahran</Details>
<Location>Dhahran</Location>
</Tracking>
<Tracking diffgr:id="Tracking8" msdata:rowOrder="7">
<awbno>290340366704</awbno>
<Date>18 Sep 2022 14:20</Date>
<Activity>DATA RECEIVED</Activity>
<Details>Online Data Submitted</Details>
<Location>NA</Location>
</Tracking>
</NewDataSet>
</diffgr:diffgram>
</getTrackingResult>
</getTrackingResponse>
</soap:Body>
</soap:Envelope>';
FOR c IN (SELECT awbno
FROM XMLTABLE (
xmlnamespaces ('urn:schemas-microsoft-com:xml-msdata' as "msdata",
'urn:schemas-microsoft-com:xml-diffgram-v1' as "diffgr",
DEFAULT 'http://track.smsaexpress.com/secom/SMSAWebserviceIntl',
'http://schemas.xmlsoap.org/soap/envelope/' AS "soap"),
'soap:Envelope/soap:Body/getTrackingResponse/getTrackingResult/diffgr:diffgram/NewDataSet/Tracking/*'
PASSING xmltype (v_xml)
COLUMNS awbno VARCHAR (100) PATH './awbno'))
LOOP
DBMS_OUTPUT.put_line (c.awbno);
END LOOP;
END;