无法使用 XMLQuery 从 SOAP Web 服务响应中获取值



我正在使用Oracle的XMLQuery数据库函数来读取SOAP Webservice响应,但是响应元素"result"在元素名称旁边包含命名空间子句(xmlns="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/"(,因此XMLQuery无法读取元素的值。

这是我收到的 Web 服务响应正文,我正在尝试读取"结果">

<env:Body>
<ns0:getFlowTaskInstanceStatusResponse xmlns:ns0="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/">
<result xmlns="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/">COMPLETED</result>
</ns0:getFlowTaskInstanceStatusResponse>
</env:Body>
.
The following Select statement returns NULL

SELECT xmlcast(XMLQuery('//result' PASSING l_xmldata RETURNING CONTENT) as varchar2(900))
into l_extract
from dual;

XMLQuery 函数将返回"已完成",以防我从 XML 响应中删除命名空间文本!!但是,这不是一个实用的解决方法。

BR 汉尼

您有两个选择(我添加了一个"env"命名空间以使 xml 有效(:

在查询中包含命名空间:

WITH test AS
(SELECT xmltype(' 
<env:Body xmlns:env="myenv">        
<ns0:getFlowTaskInstanceStatusResponse xmlns:ns0="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/">        
<result xmlns="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/">COMPLETED</result>        
</ns0:getFlowTaskInstanceStatusResponse>
</env:Body>') AS data
FROM dual
)
SELECT CAST( extractValue(test.data, '//ns0:result','xmlns:env="myenv" xmlns:ns0="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/') AS VARCHAR2(900) )
FROM test

忽略命名空间

WITH test AS
(SELECT xmltype(' 
<env:Body xmlns:env="myenv">        
<ns0:getFlowTaskInstanceStatusResponse xmlns:ns0="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/">        
<result xmlns="http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/">COMPLETED</result>        
</ns0:getFlowTaskInstanceStatusResponse>
</env:Body>') AS data
FROM dual
)
SELECT CAST( extractValue(test.data, '//*[local-name() = "result"]') AS VARCHAR2(900) )
FROM test

相关内容

  • 没有找到相关文章

最新更新