Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用示例解析Oracle中的SOAP XML_Xml_Oracle_Soap - Fatal编程技术网

用示例解析Oracle中的SOAP XML

用示例解析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

下面是表“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 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:请查看此请求。