如何从标签VertexApplicationException和User login failed.从下面的xml结果中提取值?
在我的包中,我使用‘message’调用来获取从顶点计算出来的税额,有时我收到错误作为api调用的响应,现在我需要将响应存储在表中,但只需要错误消息ex: VertexApplicationException和用户登录失败。从下面的xml响应标记
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<nsf:Fault xmlns:nsf="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>nsf:Client</faultcode>
<faultstring>User login failed.</faultstring>
<detail>
<ns:VertexException xmlns:ns="urn:vertexinc:oseries:exception:1:0">
<ns:exceptionType>VertexApplicationException</ns:exceptionType>
<ns:rootCause>User login failed.</ns:rootCause>
</ns:VertexException>
</detail>`enter code here`
</nsf:Fault>
</S:Body>
</S:Envelope>发布于 2019-12-03 07:47:25
您可以尝试以下查询:
select a.* from XMLTABLE (
xmlnamespaces( 'http://schemas.xmlsoap.org/soap/envelope/' as "S",
'http://schemas.xmlsoap.org/soap/envelope/' as "nsf",
'urn:vertexinc:oseries:exception:1:0' as "ns"),
'
/S:Envelope/S:Body/nsf:Fault/detail/ns:VertexException
'
PASSING
XMLTYPE(
'
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<nsf:Fault xmlns:nsf="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>nsf:Client</faultcode>
<faultstring>User login failed.</faultstring>
<detail>
<ns:VertexException xmlns:ns="urn:vertexinc:oseries:exception:1:0">
<ns:exceptionType>VertexApplicationException</ns:exceptionType>
<ns:rootCause>User login failed.</ns:rootCause>
</ns:VertexException>
</detail>`enter code here`
</nsf:Fault>
</S:Body>
</S:Envelope>
')
columns
ExceptionType varchar2(40) path 'ns:exceptionType'
, RootCause varchar2(40) path 'ns:rootCause'
) AS A
; 输出
+----------------------------+--------------------+
| EXCEPTIONTYPE | ROOTCAUSE |
+----------------------------+--------------------+
| VertexApplicationException | User login failed. |
+----------------------------+--------------------+发布于 2019-12-03 06:45:17
这将使您非常接近,但是XML特定的查询也可能完成此工作。
regexp_substr(your_string, '<ns:rootCause>([A-Z]*)(.*)')https://stackoverflow.com/questions/59136796
复制相似问题