oracle - 在 PLSQL 中解析 SOAP 响应
问题描述
我正在尝试解析plsql 中webservice
的 JAVA 返回的 SOAP 响应。webservice
我没有遇到任何错误,但我什么也没得到。下面是代码
WITH t as (select XMLTYPE('<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:helloResponse xmlns:ns2="http://example.com/">
<ns2:return>Hello World</ns2:return>
</ns2:helloResponse>
</S:Body>
</S:Envelope>') as xml from dual)
select *
from t,
xmltable(XMLNAMESPACES('http://example.com/' as "ns2"),
'/Envelope/Body'
passing t.xml
columns myret varchar2(50) path '/ns2:helloResponse/ns2:return'
) x
我在这里做错了什么?
解决方案
我可以在这里看到几个问题....
1)您有两个命名空间(一个用于信封和正文,另一个用于节点),您需要在选择中考虑这两者
2) 在您的 MyRet 路径中,上下文来自信封,因此您需要指定完整路径或在开头使用 //。
我正在对您实际想要的输出做出一些假设,但我认为以下内容应该适合您。
WITH t as (select XMLTYPE('<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:helloResponse xmlns:ns2="http://example.com/">
<ns2:return>Hello World</ns2:return>
</ns2:helloResponse>
</S:Body>
</S:Envelope>') as xml from dual)
select *
from t,
xmltable(XMLNAMESPACES('http://example.com/' as "ns2", 'http://schemas.xmlsoap.org/soap/envelope/' as "S"),
'/S:Envelope/S:Body'
passing t.xml
columns myret varchar2(50) path '//ns2:helloResponse/ns2:return'
) x
推荐阅读
- aem - AEM 响应式网格将自定义按钮添加到编辑栏
- r - 如何在 R 例如 5-10 的列中对范围内的值进行分组?
- types - 'and'类型说明符不应该短路吗?
- android - 添加华为套件时出现“找不到 com.huawei.hms:location:6.0.0.302”错误
- android - 小米9T如何在没有网络的情况下获取当前位置?
- android - 如何在作为选项卡的 2 个片段之间共享视图模型
- reactjs - 从 reactjs 数据文件中的文件夹加载图像并传递给 jsx 文件
- python - Numpy:如何使用在另一个矩阵的行中找到的索引来索引一个矩阵的行?
- javascript - for 循环遍历日期以检查是否相同
- azure-devops - 提取任务时 Azure devops 代理失败:目录不为空