2017-04-06 139 views
3

我試圖解析XML響應,但得到沒有給出數據found.Code解析SOAP響應below.Anyone請幫我如何使用PLSQL的Oracle APEX

WITH DATA AS (SELECT '<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> 
 
     <GetDeliveryReportResponse xmlns="MyTest WebService"> 
 
     <GetDeliveryReportResult>919748021520500 -3-4/6/2017 1:18:49 PM,919400159619-3-4/6/2017 1:19:20 PM,||rc_smsSND_NUMB-11-4/6/2017 6:10:00 PM,||rc_smsSND_NUMB-11-4/6/2017 6:11:00 PM</GetDeliveryReportResult> 
 
     </GetDeliveryReportResponse> 
 
    </soap:Body> 
 
</soap:Envelope>' xml FROM dual) 
 

 
SELECT did 
 
    FROM data, 
 
      xmltable(XMLNamespaces ('http://schemas.xmlsoap.org/soap/envelope/' 
 
            AS "soap"), 
 
        '/soap:Envelope/soap:Body/GetDeliveryReportResponse' 
 
        PASSING XMLTYPE(xml) 
 
        COLUMNS 
 
        did Varchar2(1000) PATH 'GetDeliveryReportResult');

回答

0

你只需要將默認聲明添加到已寫入的代碼中。

WITH DATA AS (SELECT '<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> 
     <GetDeliveryReportResponse xmlns="MyTest WebService"> 
     <GetDeliveryReportResult>919748021520500 -3-4/6/2017 1:18:49 PM,919400159619-3-4/6/2017 1:19:20 PM,||rc_smsSND_NUMB-11-4/6/2017 6:10:00 PM,||rc_smsSND_NUMB-11-4/6/2017 6:11:00 PM</GetDeliveryReportResult> 
     </GetDeliveryReportResponse> 
    </soap:Body> 
</soap:Envelope>' xml FROM dual) 

SELECT did 
    FROM data, 
      xmltable(XMLNamespaces (default 'MyTest WebService', 
      'http://schemas.xmlsoap.org/soap/envelope/' 
            AS "soap"), 
        '/soap:Envelope/soap:Body/GetDeliveryReportResponse' 
        PASSING XMLTYPE(xml) 
        COLUMNS 
        did Varchar2(1000) PATH 'GetDeliveryReportResult');