Extract XPath from SOAP Request Body String in BPEL

I am writing a BPEL process using JDeveloper. I ran into a problem when I try to extract the node value from my xml request.

The XML request will look like this:

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

I can extract the XML query string from the SOAP body and put it in another string variable (say strRequest).

I am trying to extract the node temperature (i.e. 200) from this strRequest variable. I will convert it to a number and assign it to another variable of type double.

What should be my XPath request for a function to retrieve the temperature value of a node?

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

I 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 similar combinations. Yield: NaN for all of the above tests.

+4
source share
2 answers

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

because '200' is a text node in the Temperature node section

0
source

you have a default namespace, so maybe you need to consider this. im not sure if in BPEL there is a special way to do this, but in general the xpath syntax, you must set xpath for 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(xx, '/*[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 
0
source

All Articles