title: How to link a soap request and response in mule 3
body: <p>I need to send a file to a external web service. When the response is <code>1</code>, the file should be deleted, else the file should be kept.</p>
  
  <p>I use the file connector to send the file, and insert a record into Oracle. When the file is sent out, the key is the message id of the file connect. I want to keep the message id so that I can update the record using this id when the response is back.</p>
  
  <p>I tried to use MessagePropertiesTransformer to add a custom property, but the response doesn't preserve it. Is there any way to keep the message id?</p>
  
  <p>My config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;mule xmlns="http://www.mulesoft.org/schema/mule/core"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:file="http://www.mulesoft.org/schema/mule/file"
        xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
        xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
        xmlns:spring="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
        xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
        xsi:schemaLocation="
            http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.1/mule-file.xsd
            http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
            http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd
            http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.1/mule-cxf.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/3.1/mule-jdbc.xsd
            http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd  
            "&gt;    
    &lt;spring:bean id="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown"&gt;
      &lt;spring:property name="driverName" value="oracle.jdbc.driver.OracleDriver"/&gt;
      &lt;spring:property name="url" value="jdbc:oracle:thin:user/pass@ip:1521:orcl"/&gt;
    &lt;/spring:bean&gt;
    &lt;file:connector name="output" outputAppend="true" outputPattern="#[function:datestamp]-#[header:originalFilename]" /&gt;
    &lt;file:connector name="input" streaming="false" recursive="true" autoDelete="false"&gt; 
  
            &lt;service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory" /&gt; 
  
    &lt;/file:connector&gt;
          &lt;jdbc:connector name="jdbcConnector" pollingFrequency="10000" dataSource-ref="jdbcDataSource"&gt;
             &lt;jdbc:query key="outboundInsertStatement"
                value="INSERT INTO TEST_MESSAGE (message_id, filename, done) VALUES (#[message:id], 
                      #[header:originalFilename], #[string:0])"/&gt;
          &lt;/jdbc:connector&gt; 
          &lt;mulexml:namespace-manager includeConfigNamespaces="true"&gt;
                  &lt;mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/&gt;
                  &lt;mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/&gt;
                  &lt;mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/&gt;
                  &lt;mulexml:namespace prefix="fullmodel" uri="iesb.dongfang.com"/&gt;
          &lt;/mulexml:namespace-manager&gt; 
      &lt;flow name="fileTestFlow1"&gt;
  
           &lt;file:inbound-endpoint path="D:/data/in" moveToDirectory="D:/data/out" moveToPattern="#[message:id]-#[header:originalFilename]" connector-ref="input"/&gt;
              &lt;component class="com.component.FileNameExtract"/&gt; 
  
           &lt;message-properties-transformer scope="outbound"&gt;
  
                  &lt;add-message-property key="test" value="#[message:id]"/&gt;
           &lt;/message-properties-transformer&gt;       
           &lt;jdbc:outbound-endpoint queryKey="outboundInsertStatement"/&gt;         
           &lt;cxf:jaxws-client
                 clientClass="com.ws.IESBService"
                 port="IESBServiceEndpoint"               
                 wsdlLocation="classpath:IESBService.wsdl"
                 operation="requestInfo"/&gt;               
           &lt;outbound-endpoint address="http://ip:8888/axis2/services/iESBService/" exchange-pattern="request-response"&gt;           
           &lt;/outbound-endpoint&gt;         
           &lt;xml-entity-decoder-transformer/&gt;                   
           &lt;logger message=" #[header:test] !" level="INFO"&gt;&lt;/logger&gt;        
      &lt;/flow&gt;   
  &lt;/mule&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong>:
  I tried "session" scope and I think it works. New config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;mule xmlns="http://www.mulesoft.org/schema/mule/core"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:file="http://www.mulesoft.org/schema/mule/file"
        xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
        xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
        xmlns:spring="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
        xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
        xsi:schemaLocation="
            http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.1/mule-file.xsd
            http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
            http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd
            http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.1/mule-cxf.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/3.1/mule-jdbc.xsd
            http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd  
            "&gt;    
    &lt;spring:bean id="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown"&gt;
      &lt;spring:property name="driverName" value="oracle.jdbc.driver.OracleDriver"/&gt;
      &lt;spring:property name="url" value="jdbc:oracle:thin:user/pass@ip:1521:orcl"/&gt;
    &lt;/spring:bean&gt;
    &lt;file:connector name="output" outputAppend="true" outputPattern="#[function:datestamp]-#[header:originalFilename]" /&gt;
    &lt;file:connector name="input" streaming="false" recursive="true" autoDelete="false"&gt; 
  
            &lt;service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory" /&gt; 
  
    &lt;/file:connector&gt;
          &lt;jdbc:connector name="jdbcConnector" pollingFrequency="10000" dataSource-ref="jdbcDataSource"&gt;
             &lt;jdbc:query key="outboundInsertStatement"
                value="INSERT INTO TEST_MESSAGE (message_id, filename, done) VALUES (#[message:id], 
                      #[header:originalFilename], #[string:0])"/&gt;
             &lt;jdbc:query key="outboundUpdateStatement"
                value="update TEST_MESSAGE set done='1' where message_id=#[header:SESSION:test] "/&gt;
          &lt;/jdbc:connector&gt; 
          &lt;mulexml:namespace-manager includeConfigNamespaces="true"&gt;
                  &lt;mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/&gt;
                  &lt;mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/&gt;
                  &lt;mulexml:namespace prefix="ns1" uri="http://www.iec.ch/TC57/2008/schema/message"/&gt;
                  &lt;mulexml:namespace prefix="fullmodel" uri="iesb.dongfang.com"/&gt;
          &lt;/mulexml:namespace-manager&gt; 
      &lt;flow name="fileTestFlow1"&gt;
  
           &lt;file:inbound-endpoint path="D:/data/in" moveToDirectory="D:/data/out" moveToPattern="#[message:id]-#[header:originalFilename]" connector-ref="input"/&gt;
              &lt;component class="com.component.FileNameExtract"/&gt; 
  
           &lt;message-properties-transformer scope="outbound"&gt;
  
                  &lt;add-message-property key="test" value="#[message:id]"/&gt;
           &lt;/message-properties-transformer&gt; 
           &lt;logger message="first #[message:id] " level="INFO"&gt;&lt;/logger&gt;      
           &lt;jdbc:outbound-endpoint queryKey="outboundInsertStatement"/&gt;         
           &lt;cxf:jaxws-client
                 clientClass="com.ws.IESBService"
                 port="IESBServiceEndpoint"               
                 wsdlLocation="classpath:IESBService.wsdl"
                 operation="requestInfo"/&gt;               
           &lt;outbound-endpoint address="http://ip:8888/axis2/services/iESBService/" exchange-pattern="request-response"&gt;           
           &lt;/outbound-endpoint&gt;         
           &lt;xml-entity-decoder-transformer/&gt;                   
           &lt;jdbc:outbound-endpoint queryKey="outboundUpdateStatement"/&gt;
           &lt;logger message="second #[header:SESSION:test] " level="INFO"&gt;&lt;/logger&gt;       
      &lt;/flow&gt;   
  &lt;/mule&gt;
  </code></pre>
  
  <p>When I copy the file one by one, it's ok, but when I copy more than five files to the directory, some records can't be updated.</p>
  
  <pre><code> Executing SQL statement: 0 row(s) updated
  </code></pre>