Announcement Announcement Module
Collapse
No announcement yet.
xpath-header-enricher : The 'sequenceNumber' header value must be an Integer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • xpath-header-enricher : The 'sequenceNumber' header value must be an Integer

    Hi,

    I use Xpath-header-enricher to extract an sequenceNumber from a XML message.
    My sequence number is the following :
    Code:
    <Root>
    <Message id="1" .../>
    </Root>
    My definition for the enricher is the following:

    Code:
    <int-xml:xpath-header-enricher
    	id="..."
    	input-channel="channel1"                      
    	output-channel="channel2"
    	default-overwrite="true">                               
    <int-xml:header name="sequenceNumber"                               
            evaluation-type="NUMBER_RESULT"       
            overwrite="true"                      
            xpath-expression="/Root/Message/@Id"/>
    </int-xml:xpath-header-enricher>
    However, my sequenceNumber is interpreted as a Double and not as an Integer, so my message gets rejected.
    Obviously the solution could be to have a transformer with XPath extraction, but it is redundant with xml path header enricher.

    How could I resolve this? Is this a bad usage of api? Is this a bug?

    Thx,

    Mayeul

  • #2
    Hello

    Try this one:
    HTML Code:
    <chain input-channel="input" output-channel="output">
        <int-xml:xpath-header-enricher>
    	<int-xml:header name="mySequenceNumber" xpath-expression="/Root/Message/@Id" evaluation-type="NUMBER_RESULT" />
        </int-xml:xpath-header-enricher>
        <header-enricher>
    	<header name="sequenceNumber" expression="headers.mySequenceNumber.intValue()"/>
        </header-enricher>
    </chain>
    The main problem is lying in the org.springframework.xml.xpath.XPathExpression#eval uateAsNumber(), when it delegates to some XPath API implementation and try to return Double. On the other side sequenceNumber should be an Integer.
    So right now it is impossible to get int value from xpath-expression.

    Nevertheless, you can open an JIRA issue (https://jira.springsource.org/browse/INT) and we will think about something like this:
    org.springframework.integration.xml.xpath.XPathEva luationType
    Code:
    INT_RESULT {
    		public Object evaluateXPath(XPathExpression expression, Node node) {
    			return ((Double) expression.evaluateAsNumber(node)).intValue();
    		}
    	},
    Cheers,
    Artem Bilan

    Comment

    Working...
    X