【问题标题】:ORACLE PL SQL Extracting a value from SOAP XMLORACLE PL SQL 从 SOAP XML 中提取值
【发布时间】:2018-03-09 21:33:11
【问题描述】:

我有一个使用 UTL_HTTP 向 SOAP 服务发出请求的 oracle 程序

这里是返回的响应,如 dbms_output.put_line(responseText); 所证明的那样;

<?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>
<CreateProductionTicketResponse xmlns="http://tempuri.org/">
<CreateProductionTicketResult>246300</CreateProductionTicketResult>
<err />
</CreateProductionTicketResponse>
</soap:Body>
</soap:Envelope>

然后我创建一个 XMLTYPE 对象

responseXml := XMLTYPE(responseText);

并尝试提取 CreateProductionTicketResult 的值

TICKET_ID := responseXML.EXTRACT('/soap:Envelope/soap:Body/CreateProductionTicketResponse/CreateProductionTicketResult/text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"').getnumberval();

这行报错

ORA-30625: method dispatch on NULL SELF argument is disallowed
ORA-06512: at line 41
30625. 00000 -  "method dispatch on NULL SELF argument is disallowed"
*Cause:    A member method of a type is being invoked with a NULL SELF
           argument.
*Action:   Change the method invocation to pass in a valid self argument.

我猜我搞砸了 EXTRACT 语法,但我不知道出了什么问题。

【问题讨论】:

    标签: xml oracle plsql


    【解决方案1】:

    问题是响应节点中的第二个未命名命名空间(并由结果节点隐式继承)。您可以在要提取的第二个参数中为其指定一个虚拟名称,并在 XPath 中使用该名称(只要 URL 匹配,名称就不必与原始文档匹配):

    TICKET_ID := responseXML.EXTRACT('/soap:Envelope/soap:Body/anon:CreateProductionTicketResponse/anon:CreateProductionTicketResult/text()',
                   'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:anon="http://tempuri.org/"').getnumberval();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-19
      • 1970-01-01
      • 2013-07-30
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 2014-01-19
      相关资源
      最近更新 更多