title: Mule 3.2: How to modify the incoming SOAP payload
body: <p><br />
  I have a question regarding Mule ESB and how to manipulate the response to an incoming SOAP request.
  The use-case scenario is this: <br />
  <b>incoming SOAP request --> take request and send to async flow for processing --> return the message ID for the Mule transaction back to the caller in the SOAP response --> (async processing of the original request continues)</b><br />
  In this scenario the resut of the SOAP request processing is not relevant to the caller. </p>
  
  <pre><code>&lt;flow name="asyncTestFlow1" doc:name="asyncTestFlow1"&gt;
      &lt;http:inbound-endpoint exchange-pattern="request-response"
          host="localhost" port="8088" doc:name="HTTP" /&gt;
      &lt;logger message="F1: messageID:#[message:id]" level="INFO" /&gt;
      &lt;async doc:name="Async"&gt;
          &lt;flow-ref name="asyncTestFlow2" doc:name="Flow Reference" /&gt;
      &lt;/async&gt;
  
      &lt;!-- ### need to modify the request, add the message ID and send back to the client ### --&gt;
  &lt;/flow&gt;
  
  &lt;flow name="asyncTestFlow2"&gt;
      &lt;cxf:proxy-service payload="body" soapVersion="1.2" doc:name="SOAP" /&gt;
      &lt;logger message="after cxf:proxy-service -&gt; #[groovy:payload.getClass()]" level="INFO" /&gt;
  
      &lt;cxf:proxy-client payload="body" enableMuleSoapHeaders="true" soapVersion="1.2" doc:name="SOAP" /&gt;
  
      &lt;http:outbound-endpoint exchange-pattern="request-response"
          address="http://example.net/KnowYourClient/KYCService"
          doc:name="HTTP" /&gt;
  
      &lt;logger message="SOAP response: #[payload:java.lang.String]" level="INFO" /&gt;
  &lt;/flow&gt;
  </code></pre>
  
  <p></p>
  
  <p>Around line 9, I added a comment where I would like to modify the payload of the request / response. I am thinking that I need a custom message transformer but I do not know where to start. I can get the input as either ContentLengthInputStream (default incoming) or as DepthXMLStreamReader (after calling cxf:proxy-service). I think in the XML format it would be easier to manipulate.. <br />
  Can someone please point me in the right direction on how to get started in manipulating that XML content?</p>
  
  <p>thank you,
  Markus</p>
  
  <p><br/><br/><br/>
  <b>--update--working example now</b><br/>
  I think I got it working now.. the key was the initial object to bye array transformer which allows to consume the incoming message in the private flow.</p>
  
  <pre><code>&lt;flow name="asyncTestFlow1" doc:name="asyncTestFlow1"&gt;
      &lt;http:inbound-endpoint exchange-pattern="request-response"  host="localhost" port="8088" doc:name="HTTP" /&gt;
      &lt;object-to-byte-array-transformer /&gt;
      &lt;logger message="F1: messageID:#[message:id]" level="INFO" doc:name="Logger" /&gt;
      &lt;async doc:name="Async"&gt;
          &lt;flow-ref name="asyncTestFlow2" doc:name="Flow Reference" /&gt;
      &lt;/async&gt;
      &lt;custom-transformer class="org.mule.examples.hello.SoapResponseTransformer" doc:name="Java" /&gt;
  &lt;/flow&gt;
  
  &lt;flow name="asyncTestFlow2" doc:name="asyncTestFlow2"&gt;
      &lt;cxf:proxy-service payload="body" soapVersion="1.2" doc:name="SOAP"/&gt; 
      &lt;cxf:proxy-client payload="body" enableMuleSoapHeaders="true" soapVersion="1.2" doc:name="SOAP"/&gt;
      &lt;http:outbound-endpoint exchange-pattern="request-response"
          address="http://.../Service"
          doc:name="HTTP" /&gt;
      &lt;logger message="SOAP response: #[payload:java.lang.String]" level="INFO" doc:name="Logger" /&gt;
  &lt;/flow&gt;
  </code></pre>