Tried that, but for some reason it fails to give me the expected results as it stops processing after 18,000 records whereas my "hack" finishes correctly after 34254 records.
On 12/3/12 11:23 PM, "Christian Müller" <[email protected]> wrote: >Indeed, this is clunky... ;-) >You should be able to do >ns.xpath("/soapenv:Envelope/soapenv:Body/ns1:getItemsResponse/ns1:out/ns1: >totalRecordsAvailable", >Integer.class) >or >ns.xpath("/soapenv:Envelope/soapenv:Body/ns1:getItemsResponse/ns1:out/ns1: >totalRecordsAvailable/text()", >Integer.class) > >Doesn't it work for you? > >Best, >Christian > >On Tue, Dec 4, 2012 at 4:00 AM, Jason Chaffee ><[email protected]>wrote: > >> Currently, I am using Xpath to read some elements from the body that are >> integers. Later in the process, I need to use those integers in a >> scripting language to do some comparisons and arithmetic. The problem >>I am >> seeing is that when I set the header it is a NodeList object instead of >>the >> integer or string from the XML, this causes the logic in the javascript >>to >> fail. I was able to work around the issue, but accessing the NodeList >>in a >> Processor and converting it and saving it back in the header. However, >> this seems very clunky and an extra step that I would expect to have to >>do. >> >> Code example is below, is there a better or cleaner way? >> >> val ns: Namespaces = new Namespaces("soapenv", " >> http://schemas.xmlsoap.org/soap/envelope/") >> ns.add("ns1", "https://foobar.com/item/v2") >> >> >> from("seda:Soap") >> .routeId("Soap") >> .setHeader("SOAPAction", constant("\"getItems\"")) >> .to("cxf://" + savingsUri.toString()) >> .unmarshal().string("UTF-8") >> .setHeader("hasMore", >> >>ns.xpath("/soapenv:Envelope/soapenv:Body/ns1:getItemsResponse/ns1:out/ns1 >>:hasMore/text()")) >> .setHeader("recordsReturned", >> >>ns.xpath("/soapenv:Envelope/soapenv:Body/ns1:getItemsResponse/ns1:out/ns1 >>:recordsReturned/text()")) >> .setHeader("totalRecordsAvailable", >> >>ns.xpath("/soapenv:Envelope/soapenv:Body/ns1:getItemsResponse/ns1:out/ns1 >>:totalRecordsAvailable/text()")) >> .process(new Processor { >> override def process(exchange: Exchange) { >> val message: Message = exchange.getIn() >> >> val hasMore: NodeList = message.getHeader("hasMore", >> classOf[NodeList]) >> message.setHeader("hasMore", hasMore.item(0).getTextContent()) >> >> val recordsReturned: NodeList = >> message.getHeader("recordsReturned", classOf[NodeList]) >> message.setHeader("recordsReturned", >> recordsReturned.item(0).getTextContent()) >> >> val totalRecordsAvailable: NodeList = >> message.getHeader("totalRecordsAvailable", classOf[NodeList]) >> message.setHeader("totalRecordsAvailable", >> totalRecordsAvailable.item(0).getTextContent()) >> } >> }) >> .choice() >> >> >>.when().javaScript("parseInt(request.headers.get('totalRecordsAvailable') >>) >> > parseInt(request.headers.get('StartIndex'))") >> >> >>.setHeader("StartIndex").javaScript("(parseInt(request.headers.get('Savin >>gsStartIndex')) >> + parseInt(request.headers.get('SavingsPageSize'))).toFixed()") >> .choice() >> >> >>.when().javaScript("parseInt(request.headers.get('totalRecordsAvailable') >>) >> - parseInt(request.headers.get('StartIndex')) < >> parseInt(request.headers.get('PageSize'))") >> >> >>.setHeader("PageSize").javaScript("(parseInt(request.headers.get('totalRe >>cordsAvailable')) >> - parseInt(request.headers.get('StartIndex'))).toFixed()") >> .endChoice() >> .wireTap("seda:CreateMessage") >> .endChoice() >> .split() >> .tokenizeXML("ns1:items") >> .parallelProcessing() >> .streaming() >> .to("jms:queue:Split") >> >> > > >--
