【问题标题】:How to read the Result header XML tag in PL/SQL如何在 PL/SQL 中读取 Result 标头 XML 标记
【发布时间】:2016-10-14 13:54:58
【问题描述】:

肥皂反应:

s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
  <GetResponse xmlns="http://temp.org/">
     <GetResult xmlns:a="http://schemas.datacontract.org/2004/07/ST" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <a:ResultHeader xmlns:b="http://schemas.datacontract.org/2004/07/CRM">
           <b:ResultCode>0000</b:ResultCode>
           <b:ResultDescription>Successful</b:ResultDescription>

           <b:TranscationID>?</b:TranscationID>
        </a:ResultHeader>

请建议我如何通过 pl/SQL 读取响应 xml 中的结果代码和结果描述,如果结果代码是 000,那么我将读取其他子节点值,否则代码不是 000,那么它将向用户显示异常。

【问题讨论】:

  • 我认为你使用了错误的工具来完成这项工作,使用 xml 解析器在应用程序端应该会更好

标签: xml plsql


【解决方案1】:

如果您的 XML 中只有一个 ResultHeader 节点,那么您可以通过这种方式检查 ResultCode

   -- get ResultCode value     
   l_resultCode:=  l_xml.extract('/s:Envelope/s:Body/GetResponse/GetResult/a:ResultHeader/b:ResultCode/text()', 'xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/ xmlns:a="http://schemas.datacontract.org/2004/07/CRM" xmlns:b="http://schemas.datacontract.org/2004/07/CRM"').GetStringVal(); 

   -- check ResultCode
   IF l_resultCode = '000' THEN
       -- if OK then get value from child nodes  
   ELSE
       -- else raise exception
       l_resultDescription:= l_xml.extract('/s:Envelope/s:Body/GetResponse/GetResult/a:ResultHeader/b:ResultDescription/text()', 'xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/ xmlns:a="http://schemas.datacontract.org/2004/07/CRM" xmlns:b="http://schemas.datacontract.org/2004/07/CRM"').GetStringVal(); 
       raise_application_error(-20001, 'ResultCode='||l_resultCode||', ResultDescription='||l_resultDescription);
   END IF;    

【讨论】:

    猜你喜欢
    • 2018-08-03
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    • 1970-01-01
    • 2013-01-15
    相关资源
    最近更新 更多