Mule Esb 3.2.1:收集拆分器的结果并以XML格式输出结果

时间:2012-03-06 09:34:29

标签: esb mule

我一直在努力通过SO和Mule论坛,但找不到有效的解决方案。 esb接收包含id的单个请求,该请求创建由相关id列表组成的XML有效负载。然后将此XML有效负载拆分并发送到转换器,该转换器获取每个相关的id以获取一些元数据。然后应该将结果组合在一起以进行XML响应。我遇到的问题是,无论我如何转换最终结果集,我总是使用封装字符串“?? sr”java.util.concurrent.CopyOnWriteArrayListx] ....“”x

非常感谢任何想法/评论。

这是我正在使用的mule-config:


<http:connector name="HttpConnector" doc:name="HTTP\HTTPS"/>
<expression-transformer name="ExtractId" doc:name="Expression">
    <return-argument evaluator="xpath" expression="//string[1]"/>
</expression-transformer>
<flow name="myFlow1" doc:name="myFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="incoming/path/" connector-ref="HttpConnector" doc:name="HTTP"/>
    <custom-transformer encoding="UTF-8" class="mycomponents.transformers.SubscriberRequestTransformer" doc:name="Create Hub Id Requests"/>
    <mulexml:object-to-xml-transformer doc:name="Object to XML"/>

    <splitter evaluator="xpath" expression="//entry/list/string" enableCorrelation="ALWAYS" doc:name="Splitter"/>
    <transformer ref="ExtractId" doc:name="Transformer Reference"/>
    <logger message="#[payload:]" level="INFO" doc:name="Logger"/>
    <custom-transformer encoding="UTF-8" class="mycomponents.transformers.HubQueryProcessor" doc:name="Create Hub Id Requests"/>
    <collection-aggregator />
    <component  class="mycomponents.TopicResponseAggregatorComponent" doc:name="Collect requests" />
    <logger message="Aggregated Content (#[groovy:payload.size()] elements): \n#[payload:]" level="INFO" doc:name="Logger"/>        
    <logger message="#[payload:]" level="INFO" doc:name="Logger"/>

</flow>

我已经解决了这个问题。虽然我不太明白为什么它不同但我认为它与一些骡子“魔法”有关。我将流量分成多个流量,这是我最终要做的事情。然而,通过这样做,问题就消失了。

仅供参考:这是更新的流程:

<flow name="myFlow1" doc:name="myFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="url/for/service/" connector-ref="HttpConnector" doc:name="HTTP"/>
    <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)"/>
    <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"/>
    <flow-ref name="buildResponseFlow" doc:name="Build final response" doc:description="piece all the messages together into a single object as a string"/>

    <response>
        <message-properties-transformer>
            <add-message-property value="text/xml" key="Content-Type" />
        </message-properties-transformer>
    </response>
</flow>

1 个答案:

答案 0 :(得分:3)

默认情况下,消息属性转换器将新属性存储在“调用”范围中。您需要在“出站”范围内设置内容类型,以便入站HTTP端点在其响应阶段使用它。

试试这个:

    <response>
        <message-properties-transformer scope="outbound">
            <add-message-property value="text/xml" key="Content-Type" />
        </message-properties-transformer>
    </response>