title: Mule Esb 3.2.1: gathering the results of a splitter and outputting results as XML
body: <p>I've been struggling through SO and the Mule forums but can't find a solution that works.  The esb takes in a single request containing an id, which creates an XML payload that is composed a list of related ids.  This XML payload is then split and sent to a transformer that takes each related id to get some meta data.  The results are then supposed to be combined together to make an XML response.  The problem I am having is that no matter how I transform the final result set, I always get back the document with an encapsulating string "??sr)java.util.concurrent.CopyOnWriteArrayListx]....""x</p>
  
  <p>Any ideas/comments would be greatly appreciated.</p>
  
  <p>Here is the mule-config I am using:</p>
  
  <hr>
  
  <pre><code>&lt;http:connector name="HttpConnector" doc:name="HTTP\HTTPS"/&gt;
  &lt;expression-transformer name="ExtractId" doc:name="Expression"&gt;
      &lt;return-argument evaluator="xpath" expression="//string[1]"/&gt;
  &lt;/expression-transformer&gt;
  &lt;flow name="myFlow1" doc:name="myFlow1"&gt;
      &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="incoming/path/" connector-ref="HttpConnector" doc:name="HTTP"/&gt;
      &lt;custom-transformer encoding="UTF-8" class="mycomponents.transformers.SubscriberRequestTransformer" doc:name="Create Hub Id Requests"/&gt;
      &lt;mulexml:object-to-xml-transformer doc:name="Object to XML"/&gt;
  
      &lt;splitter evaluator="xpath" expression="//entry/list/string" enableCorrelation="ALWAYS" doc:name="Splitter"/&gt;
      &lt;transformer ref="ExtractId" doc:name="Transformer Reference"/&gt;
      &lt;logger message="#[payload:]" level="INFO" doc:name="Logger"/&gt;
      &lt;custom-transformer encoding="UTF-8" class="mycomponents.transformers.HubQueryProcessor" doc:name="Create Hub Id Requests"/&gt;
      &lt;collection-aggregator /&gt;
      &lt;component  class="mycomponents.TopicResponseAggregatorComponent" doc:name="Collect requests" /&gt;
      &lt;logger message="Aggregated Content (#[groovy:payload.size()] elements): \n#[payload:]" level="INFO" doc:name="Logger"/&gt;        
      &lt;logger message="#[payload:]" level="INFO" doc:name="Logger"/&gt;
  
  &lt;/flow&gt;
  </code></pre>
  
  <hr>
  
  <p>I've resolved the issue.  Although I don't quite understand why it's different but I'm assuming it has to do with some of the mule "magic".  I split up the flow into multiple flows which is what I was eventually going to do anyways.  However, by doing this the problem went away.</p>
  
  <p>FYI: here's the updated flow:</p>
  
  <pre><code>&lt;flow name="myFlow1" doc:name="myFlow1"&gt;
      &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="url/for/service/" connector-ref="HttpConnector" doc:name="HTTP"/&gt;
      &lt;flow-ref name="createHubIdRequestsFlow" doc:name="Map To Hub Ids" doc:description="Takes in the situation id passed in by the client.  Does the query lookup versus the content mapping tables.  creates the correspondng requests for meta data information to the provider(s)"/&gt;
      &lt;flow-ref name="getTopicRequests" doc:name="Process Provider Reponses" doc:description="For each JSON response returned from the provider, transform it into an XML representation of that data"/&gt;
      &lt;flow-ref name="buildResponseFlow" doc:name="Build final response" doc:description="piece all the messages together into a single object as a string"/&gt;
  
      &lt;response&gt;
          &lt;message-properties-transformer&gt;
              &lt;add-message-property value="text/xml" key="Content-Type" /&gt;
          &lt;/message-properties-transformer&gt;
      &lt;/response&gt;
  &lt;/flow&gt;
  </code></pre>