I've flow like this and my problem is that I'm getting the wrong value on the second header:
<when>
<xpath>//kred:assigment_GetRq/nrb</xpath>
<setHeader headerName="nrbPE">
<xpath resultType="java.lang.String">//kred:assigment_GetRq/nrb/text()</xpath>
</setHeader>
<setHeader headerName="subNrbPE">
<xpath resultType="java.lang.String">substring(${headers.nrbPE}, 3, 6)</xpath>
</setHeader>
<setHeader headerName="kod">
<simple>${properties:apiEsb.assigment.bpCode}</simple>
</setHeader>
<log loggingLevel="INFO" message="header nrb: ${headers.nrbPE}"/>
<log loggingLevel="INFO" message="header subNrb: ${headers.subNrbPE}"/>
<log loggingLevel="INFO" message="Property: ${headers.kod}"/>
<choice>
<when>
<xpath>${headers.subNrbPE} = ${headers.kod}</xpath>
<process ref="createDetailSectionProc" />
</when>
<otherwise>
<log loggingLevel="INFO" message="otherwise"/>
</otherwise>
</choice>
</when>
Logs:
08:26:47,067 | INFO | Esb| Assigment_Get | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | header nrb: 99999999
08:26:47,067 | INFO | Esb| Assigfment_Get | | 68 - org.apache.camel.camel-core - 2.6.0.fuse-03-01 | header subNrb: ass ja
I don't understand what is wrong with syntax cause the second value should be 9999, but I see that substring is making on (class java...) Could you tell me where I made a mistake? I need to compare this substring value with property value in some logic statement in Camel.
You should use below syntax:
<setHeader headerName="subNrbPE">
<xpath resultType="java.lang.String">substring($in:nrbPE, 3, 4)</xpath>
</setHeader>
because XPath substring takes
fn:substring(sourceString, startingLoc, length)
So if you want to have 4 digits, you need to specify starting position (3) and how many chars you want (4).
Also comparison should be changed to:
<simple>${headers.subNrbPE} == ${headers.kod}</simple>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.