Hi When using xpath make sure the namespace is correct and mapped etc. It can be a bit tricky to get right. As you use namespace then you need to map the prefix tns to the namespace in the camel xml file also.
On Mon, Jul 6, 2015 at 5:23 PM, Scisci <ferioli.mi...@gmail.com> wrote: > Hi, I've a problem with setHeader ad xpath. > This is my xml > > <?xml version="1.0" encoding="UTF-8"?> > <tns:Accpos xmlns:tns="http://www.gestielle.it/Accpos" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.gestielle.it/Accpos > src/main/resources/Accpos.xsd "> > <tns:Data_Giro>2015-07-01</tns:Data_Giro> > <tns:Tipo_Fondo>O</tns:Tipo_Fondo> > <tns:Items count="2"> > <tns:Item Id="1"> > <tns:Codice_Fondo>C6_O</tns:Codice_Fondo> > <tns:Numero_Conto>999998</tns:Numero_Conto> > <tns:Descrizione_Conto>Cambi Spot</tns:Descrizione_Conto> > <tns:Numero_Sottoconto>23</tns:Numero_Sottoconto> > <tns:Descrizione_Sottoconto>prova</tns:Descrizione_Sottoconto> > <tns:Divisa>DKK</tns:Divisa> > <tns:Saldo>11375.20</tns:Saldo> > </tns:Item> > <tns:Item Id="2"> > <tns:Codice_Fondo>C6_O</tns:Codice_Fondo> > <tns:Numero_Conto>91243</tns:Numero_Conto> > <tns:Descrizione_Conto>Cambi Spot</tns:Descrizione_Conto> > <tns:Numero_Sottoconto>6456</tns:Numero_Sottoconto> > <tns:Descrizione_Sottoconto>pippo</tns:Descrizione_Sottoconto> > <tns:Divisa>DKK</tns:Divisa> > <tns:Saldo>11375.20</tns:Saldo> > </tns:Item> > </tns:Items> > </tns:Accpos> > > and this is the camel root > > <route id="Accpos"> > <from > uri="file:{{Path_In}}?fileName={{File_Name_Accpos}}&readLock=changed&readLockTimeout=10000&readLockCheckInterval=5000&move={{Backup}}"/> > <doTry> > <to uri="validator:classpath:Accpos.xsd"/> > <log message="Reciving ${file:name}"/> > <setHeader headerName="Tipo_Fondo"><xpath > resultType="java.lang.String">/tns:Accpos/tns:Tipo_Fondo/text()</xpath></setHeader> > <log message="Tipo_Fondo : ${header.Tipo_Fondo}"/> > <setHeader headerName="Data_Giro"><xpath > resultType="java.lang.String">/tns:Accpos/tns:Data_Giro/text()</xpath></setHeader> > <log message="Data_Giro : ${header.Data_Giro}"/> > .... > > and this is the log > > 17:20:38,658 INFO [org.apache.camel.builder.xml.XPathBuilder] (Camel > (Risk_Files_Adepa) thread #0 - file:///opt/Spazio/Ricezione_New/ADEPA) Using > system property > javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom with value > http://java.sun.com/jaxp/xpath/dom when created default XPathFactory > __redirected.__XPathFactory@30f6e288 > 17:20:38,662 WARN [org.apache.camel.component.file.GenericFileOnCompletion] > (Camel (Risk_Files_Adepa) thread #0 - > file:///opt/Spazio/Ricezione_New/ADEPA) Rollback file strategy: > org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@357d24a3 > for file: GenericFile[/opt/Spazio/Ricezione_New/ADEPA/ACCPOS] > > the Header was not set. > Someone can help me? > > Thanks > Mirko > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/SetHeader-and-XPath-tp5768926.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/