我正在调用一个向我返回xml的web服务。当试图使用下面包含的语句获取所述响应的信息时,没有找到任何数据,也就是说,该语句不返回任何信息。我的句子中可能有什么不正确的地方,但我找不到问题所在。
我们有以下句子:
SELECT T.MYCODE
FROM XMLTABLE(XMLNAMESPACES( DEFAULT 'http://tempuri.org/',
'http://schemas.xmlsoap.org/soap/envelope/' AS "SOAP-ENV",
'http://schemas.xmlsoap.org/soap/encoding/' AS "SOAP-ENC",
'http://www.w3.org/2001/XMLSchema' AS "xsd",
'http://www.w3.org/2001/XMLSchema-instance' AS "xsi",
'http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/RateMsgResponse' AS "rateresp"),
'/SOAP-ENV:Envelope/SOAP-ENV:Body/rateresp:RateResponse/Provider'
PASSING xmltype('<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<rateresp:RateResponse xmlns:rateresp="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/RateMsgResponse">
<Provider code="DHL">
<Notification code="0">
<Message></Message>
</Notification>
<Service type="N">
<TotalNet>
<Currency>EUR</Currency>
<Amount>7.34</Amount>
</TotalNet>
<Charges>
<Currency>EUR</Currency>
<Charge>
<ChargeType>EXPRESS DOMESTIC</ChargeType>
<ChargeAmount>6.46</ChargeAmount>
</Charge>
<Charge>
<ChargeCode>FF</ChargeCode>
<ChargeType>FUEL SURCHARGE</ChargeType>
<ChargeAmount>0.88</ChargeAmount>
</Charge>
</Charges>
<DeliveryTime>2020-01-22T23:59:00</DeliveryTime>
<CutoffTime>2020-01-21T16:00:00</CutoffTime>
<NextBusinessDayInd>N</NextBusinessDayInd>
</Service>
</Provider>
</rateresp:RateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>')
COLUMNS MYCODE VARCHAR2(20) PATH '@code') t;
我原以为字符串"DHL"会返回,但它什么也没返回。我做错了什么?非常感谢。
唯一的错误是将'http://tempuri.org/'
定义为默认命名空间。但是它根本不存在于您的XML中。
您可以将默认名称空间添加到XML中,也可以删除XMLTABLE中默认名称空间的定义。