用示例解析Oracle中的SOAP XML
下面是表“external”中的一个典型SOAP请求用示例解析Oracle中的SOAP XML,xml,oracle,soap,Xml,Oracle,Soap,下面是表“external”中的一个典型SOAP请求 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <settleResponse x
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<settleResponse xmlns="urn:ABC">
<settleReturn xmlns="">
<message>Missing first name</message>
<errorCode>INVALID_ACC</errorCode>
<customData>offendingTransactionID=12345678</customData>
<divisionRequestID xsi:nil="true"/>
<status>Failed</status>
</settleReturn>
</settleResponse>
</soapenv:Body>
</soapenv:Envelope>
缺少名字
无效的_ACC
违规交易ID=12345678
失败
我需要检索参数错误代码,状态。。。并将它们保存到DB表中。我该怎么做?您可以使用
XMLQUERY
提取节点内容:
select xmlquery('declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace urn = "urn:ABC";
/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn/message/text()'
passing XMLType(message)
returning content) as message,
xmlquery('declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace urn = "urn:ABC";
/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn/errorCode/text()'
passing XMLType(message)
returning content) as errorCode,
xmlquery('declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace urn = "urn:ABC";
/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn/status/text()'
passing XMLType(message)
returning content) as status
from external;
MESSAGE ERRORCODE STATUS
-------------------- -------------------- ----------
Missing first name INVALID_ACC Failed
或者更简单地说,特别是当您要处理多条消息时,使用XMLTABLE
:
select x.*
from external ext
cross join xmltable(
xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
'urn:ABC' as "urn"),
'/soapenv:Envelope/soapenv:Body/urn:settleResponse/settleReturn'
passing XMLType(ext.message)
columns message varchar2(20) path 'message',
errorCode varchar2(20) path 'errorCode',
status varchar2(10) path 'status'
) x;
MESSAGE ERRORCODE STATUS
-------------------- -------------------- ----------
Missing first name INVALID_ACC Failed
在这两种情况下,您都需要指定名称空间,并且语法不同
您可以使用
insert into some_table(x,y,z)选择…
将这些数据直接插入另一个表中。SOAP XML位于“message”列中,数据类型为CLOB,位于表“external”中。apc:请查看此请求。