4

I am writing a BPEL process using JDeveloper. I am facing an issue when I try to extract the value of a node from my request xml.

Request XML will be as follows:

<ConvertTemp xmlns="http://www.nikhil.net/">
   <Temperature>200</Temperature>
   <FromUnit>degreeCelsius</FromUnit>
   <ToUnit>degreeFahrenheit</ToUnit>
</ConvertTemp>

I am able to extract the request XML string out of the SOAP Body and put it into another string variable (say strRequest).

I am trying to extract the value of Temperature node (which is 200) out of this strRequest variable. I will be converting it into a number and assigning it to another variable of type double.

What should be my XPath query for the function to extract the Temperature node value?

number(bpws:getVariableData('strRequest', '', '<XPath query>'))

I've tried

bpws:getVariableData('strRequest', '', '/ConvertTemp/Temperature/')
bpws:getVariableData('strRequest', '', '/ConvertTemp/Temperature')
bpws:getVariableData('strRequest', '', 'Temperature')
bpws:getVariableData('strRequest', 'strRequest', '/ConvertTemp/Temperature')
bpws:getVariableData('strRequest', 'strRequest', 'Temperature')

and similiar combinations. Output: NaN for all the trials above

Nikhil
  • 41
  • 2

2 Answers2

0

try bpws:getVariableData('strRequest', '', '/ConvertTemp/Temperature/text()')

because '200' is a text node under Temperature node

weima
  • 4,653
  • 6
  • 34
  • 55
0

you have a default namespace, so maybe you need to take that into account. im not sure if there's a special way in BPEL to do this, but in general xpath syntax, you would set the xpath to this:

/*[local-name() = "ConvertTemp" and namespace-uri() = "http://www.nikhil.net/"]/*[local-name() = "Temperature" and namespace-uri() = "http://www.nikhil.net/"]/text()

eg

with xml as (select xmltype('<ConvertTemp xmlns="http://www.nikhil.net/">
  2     <Temperature>200</Temperature>
  3     <FromUnit>degreeCelsius</FromUnit>
  4     <ToUnit>degreeFahrenheit</ToUnit>
  5  </ConvertTemp>') x from dual)
  6  select extractvalue(x.x, '/*[local-name() = "ConvertTemp" and namespace-uri() = "http://www.nikhil.net/"]'
  7  ||'/*[local-name() = "Temperature" and namespace-uri() = "http://www.nikhil.net/"]/text()') as temperature
  8    from xml x
  9  /

TEMPERATURE
--------------------------------------------------------------------------------
200
DazzaL
  • 21,638
  • 3
  • 49
  • 57