title: WSO2 ESB - XML to MySQL Database
body: <p>I need a solution for a problem:
  I just tried this example for the WSO2 ESB and it is working:
  <a href="http://wso2.org/library/articles/2011/01/wso2-esb-example-file-processing" rel="nofollow">http://wso2.org/library/articles/2011/01/wso2-esb-example-file-processing</a></p>
  
  <p>But I like to use an XML file as input and write this to a MySQL-DB.
  The XML-file looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soapenv:Body&gt;
    &lt;Name&gt;word&lt;/Name&gt;
    &lt;Surname&gt;processor&lt;/Surname&gt;
    &lt;Phone&gt;12333&lt;/Phone&gt;
  &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>If i put this into my "in"-folder the file will be moved to the "out"-folder, but nothing is written into the database. There is no error message.</p>
  
  <p>My Proxy-Service:</p>
  
  <pre><code>    &lt;proxy xmlns="http://ws.apache.org/ns/synapse" name="FileProxy" transports="vfs" statistics="disable" trace="disable" startOnLoad="true"&gt;
     &lt;target&gt;
        &lt;inSequence&gt;
           &lt;log level="full"/&gt;
           &lt;clone&gt;
              &lt;target sequence="fileWriteSequence"/&gt;
              &lt;target sequence="databaseSequence"/&gt;
           &lt;/clone&gt;
        &lt;/inSequence&gt;
     &lt;/target&gt;
     &lt;parameter name="transport.vfs.ActionAfterProcess"&gt;MOVE&lt;/parameter&gt;
     &lt;parameter name="transport.PollInterval"&gt;15&lt;/parameter&gt;
     &lt;parameter name="transport.vfs.MoveAfterProcess"&gt;C:/wso2esb/testordner/out&lt;/parameter&gt;
     &lt;parameter name="transport.vfs.FileURI"&gt;C:/wso2esb/testordner/in&lt;/parameter&gt;
     &lt;parameter name="transport.vfs.MoveAfterFailure"&gt;C:/wso2esb/testordner/error&lt;/parameter&gt;
     &lt;parameter name="transport.vfs.FileNamePattern"&gt;.*.xml&lt;/parameter&gt;
     &lt;parameter name="transport.vfs.ContentType"&gt;text/xml&lt;/parameter&gt;
     &lt;parameter name="transport.vfs.ActionAfterFailure"&gt;MOVE&lt;/parameter&gt;
     &lt;description&gt;&lt;/description&gt;
  &lt;/proxy&gt;
  </code></pre>
  
  <p>And my Sequence:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sequence xmlns="http://ws.apache.org/ns/synapse"
            name="databaseSequence"
            trace="enable"
            statistics="enable"&gt;
     &lt;log level="full"&gt;
        &lt;property name="sequence" value="before-smooks"/&gt;
     &lt;/log&gt;
     &lt;smooks config-key="smooks"&gt;
        &lt;input type="xml"/&gt;
        &lt;output type="xml"/&gt;
     &lt;/smooks&gt;
     &lt;log level="full"&gt;
        &lt;property name="sequence" value="after-smooks"/&gt;
     &lt;/log&gt;
     &lt;log level="full"&gt;
        &lt;property xmlns:ns="http://org.apache.synapse/xsd"
                  name="name"
                  expression="//csv-record/name/text()"/&gt;
        &lt;property xmlns:ns="http://org.apache.synapse/xsd"
                  name="surname"
                  expression="//csv-record/surname/text()"/&gt;
        &lt;property name="phone" value="//csv-record/phone/text()"/&gt;
     &lt;/log&gt;
     &lt;iterate xmlns:ns2="http://org.apache.synapse/xsd"
              xmlns:ns="http://org.apache.synapse/xsd"
              xmlns:sec="http://secservice.samples.esb.wso2.org"
              expression="//csv-set/csv-record"&gt;
        &lt;target&gt;
           &lt;sequence&gt;
              &lt;log level="full"&gt;
                 &lt;property name="State" value="Iteration"/&gt;
              &lt;/log&gt;
              &lt;log level="full" category="DEBUG"/&gt;
              &lt;dbreport&gt;
                 &lt;connection&gt;
                    &lt;pool&gt;
                       &lt;password&gt;passwort&lt;/password&gt;
                       &lt;user&gt;esb&lt;/user&gt;
                       &lt;url&gt;jdbc:mysql://localhost:3306/&lt;/url&gt;
                       &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt;
                    &lt;/pool&gt;
                 &lt;/connection&gt;
                 &lt;statement&gt;
                    &lt;sql&gt;insert into info.info (name, surname, phone) values (?, ?, ?)&lt;/sql&gt;
                    &lt;parameter expression="//csv-record/name/text()" type="VARCHAR"/&gt;
                    &lt;parameter expression="//csv-record/surname/text()" type="VARCHAR"/&gt;
                    &lt;parameter expression="//csv-record/phone/text()" type="VARCHAR"/&gt;
                 &lt;/statement&gt;
              &lt;/dbreport&gt;
           &lt;/sequence&gt;
        &lt;/target&gt;
     &lt;/iterate&gt;
     &lt;log level="full" category="DEBUG"/&gt;
  &lt;/sequence&gt;
  </code></pre>
  
  <p>I thought this would be a simple problem, but I'm not able to get it...
  Like I said, it's working with a normal text-file, but not with XML. I tried different thinks and have no idea what else I could try...
  Does someone know what's my mistake?</p>
  
  <p>Update:</p>
  
  <p>The log from the console:</p>
  
  <pre><code>[2013-04-12 09:35:55,687]  INFO - DBReportMediator Successfully created data source for jdbc:mysql://localhost:3306/.
  [2013-04-12 09:36:10,170]  INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
  2CBD1753113A1373101365752170177, Direction: request, Envelope: &lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope x
  mlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;
    &lt;Name&gt;word&lt;/Name&gt;
    &lt;Surname&gt;processor&lt;/Surname&gt;
    &lt;Phone&gt;12333&lt;/Phone&gt;
  &lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
  [2013-04-12 09:36:10,175]  INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
  a9252cd8-fe73-4e85-9f41-0842872d3a73, Direction: request, sequence = before-smooks, Envelope: &lt;?xml version='1.0' encodi
  ng='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;
    &lt;Name&gt;word&lt;/Name&gt;
    &lt;Surname&gt;processor&lt;/Surname&gt;
    &lt;Phone&gt;12333&lt;/Phone&gt;
  &lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
  [2013-04-12 09:36:10,178]  INFO - LogMediator sequence = fileWriteSequence
  [2013-04-12 09:36:10,246]  INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
  a9252cd8-fe73-4e85-9f41-0842872d3a73, Direction: request, sequence = after-smooks, Envelope: &lt;?xml version='1.0' encodin
  g='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Body&gt;&lt;csv-set/&gt;&lt;/soapenv
  :Body&gt;&lt;/soapenv:Envelope&gt;
  [2013-04-12 09:36:10,249]  INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
  a9252cd8-fe73-4e85-9f41-0842872d3a73, Direction: request, name = , surname = , phone = //csv-record/phone/text(), Envelo
  pe: &lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;s
  oapenv:Body&gt;&lt;csv-set/&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
  [2013-04-12 09:36:11,254]  WARN - TimeoutHandler Expiring message ID : urn:uuid:4c422f4e-aed5-4eaa-ad9b-e5407db20562; dr
  opping message after global timeout of : 120 seconds
  </code></pre>
  
  <p>The fileWriteSequence looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sequence xmlns="http://ws.apache.org/ns/synapse"
            name="fileWriteSequence"
            trace="enable"
            statistics="enable"&gt;
     &lt;log level="custom"&gt;
        &lt;property name="sequence" value="fileWriteSequence"/&gt;
     &lt;/log&gt;
     &lt;property xmlns:ns2="http://org.apache.synapse/xsd"
               xmlns:ns="http://org.apache.synapse/xsd"
               name="transport.vfs.ReplyFileName"
               expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')"
               scope="transport"
               type="STRING"/&gt;
     &lt;property name="OUT_ONLY" value="true" scope="default" type="STRING"/&gt;
     &lt;send&gt;
        &lt;endpoint name="FileEpr"&gt;
           &lt;address uri="vfs:C:/wso2esb/testordner/out"/&gt;
        &lt;/endpoint&gt;
     &lt;/send&gt;
  &lt;/sequence&gt;
  </code></pre>
  
  <p>Smooks config:</p>
  
  <pre><code>&lt;smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd"&gt;
  
    &lt;!--Configure the CSVParser to parse the message into a stream of SAX events. --&gt;
    &lt;resource-config selector="org.xml.sax.driver"&gt;
      &lt;resource&gt;org.milyn.csv.CSVParser&lt;/resource&gt;
      &lt;param name="fields" type="string-list"&gt;name,surname,phone&lt;/param&gt;
    &lt;/resource-config&gt;
  
  &lt;/smooks-resource-list&gt;
  </code></pre>
  
  <p>I also changed the code of the databaseSequence above.</p>
  
  <p>Thank you.</p>