0

i need to get "ineedthis" value from field

REQUEST_INFO:
...

<s:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<X-dynaTrace xmlns="http://ns.dynatrace.com/wcf" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">FW3;-1003312095;1;-56375709;115092;0;975784079;78</X-dynaTrace>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<storeContract xmlns="xxx/integration">
<storeRequest>
<contract>
<contractSeries>ineedthis</contractSeries>

select extractvalue(XMLType(sap.REQUEST_INFO),'s/s/storeContract/storeRequest/contract/contractSeries')
from sap

cant get the value

jarlh
  • 42,561
  • 8
  • 45
  • 63
pmipmi
  • 109
  • 1
  • 1
  • 4
  • Without knowing the complete structure of your XML, it's hard to identify the right path for `extractValue`. Can you please post a complete [simplified] XML? – Aleksej Mar 28 '19 at 09:35

1 Answers1

0

You're trying to extract the path

s/s/storeContract/storeRequest/contract/contractSeries

but your SOAP response doesn't have any nodes called s; it has nodes called Envelope, Header and Body in the namespace s. So you potentially want the path:

/s:Envelope/s:Body/storeContract/storeRequest/contract/contractSeries

which on its own gets an LPX-00601: Invalid token error because it doesn't know what s: is. You can supply the namespaces with the third argument:

select extractvalue(XMLType(sap.request_info),
  '/s:Envelope/s:Body/storeContract/storeRequest/contract/contractSeries',
  'xmlns="xxx/integration" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"'
  ) as contractseries
from sap;

or the lazy way is to wildcard the namespace and only identify the final node you want:

select extractvalue(XMLType(sap.request_info),'//*:contractSeries') as contractseries
from sap;

But extractvaue is deprecated so it's better to use XMLQuery - still being lazy:

select XMLQuery('//*:contractSeries/text()'
  passing XMLType(sap.request_info)
  returning content) as contractseries
from sap;

or with explicit namespaces:

select XMLQuery('
    declare default element namespace "xxx/integration";
    declare namespace s="http://schemas.xmlsoap.org/soap/envelope/";
    /s:Envelope/s:Body/storeContract/storeRequest/contract/contractSeries/text()'
  passing XMLType(sap.request_info)
  returning content) as contractseries
from sap;

CONTRACTSERIES                
------------------------------
ineedthis

db<>fiddle

Alex Poole
  • 183,384
  • 11
  • 179
  • 318