Mule XPath Splitter 不能超出第一个元素

Mule XPath Splitter not working beyond first element

我需要获取包含重复元素的传入 XML 消息,并将它们拆分为单独的消息以进行后续处理。然后我需要重新组合结果并通过 HTTP 响应。

我在第一步中使用了 Splitter 节点和 XPath。但是,它只访问 XML 中的第一个元素,也不会将 XML 保留到下一阶段。我试过 the example from the documentation,但它有相同的输出。

我是 Anypoint Studio 中的 运行 Mule 3.6.1 CE。

NB 元素的处理顺序很重要,因此我不想只做 Scatter-Gather。

这是我的示例 XML:-

<?xml version="1.0" encoding="UTF-8"?>
<itm:ItemList
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:itm="http://schemas.goochjs.org/item-v1"
        xsi:schemaLocation="http://schemas.goochjs.org/item-v1 item-v1.xsd">

    <itm:Item sequence="1" action="create">
        <itm:Thing type="something">
            <itm:Description>Something</itm:Description>
        </itm:Thing>

        <itm:Thing type="anything">
            <itm:Description>Something else</itm:Description>
        </itm:Thing>
    </itm:Item>

    <itm:Item sequence="2" action="update">
        <itm:Thing type="anything">
            <itm:Description>A wotsit</itm:Description>
        </itm:Thing>
    </itm:Item>

    <itm:Item sequence="2" action="create">
        <itm:Thing type="something">
            <itm:Description>A doohinky</itm:Description>
        </itm:Thing>
    </itm:Item>

    <itm:Item sequence="3" action="delete">
        <itm:Thing type="something">
            <itm:Description>A different doohinky</itm:Description>
        </itm:Thing>
    </itm:Item>
</itm:ItemList>

这是我的代码:-

<?xml version="1.0" encoding="UTF-8"?>

<mule
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
    xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.6.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
    http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <http:listener-config name="splitter-endpoint" host="0.0.0.0" port="8081" basePath="/splitter" doc:name="HTTP Listener Configuration"/>
    <mulexml:namespace-manager includeConfigNamespaces="true">
        <mulexml:namespace prefix="itm" uri="http://schemas.goochjs.org/item-v1"/>
    </mulexml:namespace-manager>

    <flow name="mule-splitter-aggregatorFlow">
        <http:listener config-ref="splitter-endpoint" path="/" allowedMethods="post" doc:name="HTTP"/>
        <splitter expression="#[xpath3('/itm:ItemList/itm:Item')]" doc:name="Splitter"/>
        <logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

这是日志中的输出:-

INFO  2015-03-19 10:48:17,440 [[mule-splitter-aggregator].splitter-endpoint.worker.01] org.mule.routing.ExpressionSplitter: The expression does not evaluate to a type that can be split: java.lang.String
INFO  2015-03-19 10:48:17,441 [[mule-splitter-aggregator].splitter-endpoint.worker.01] org.mule.api.processor.LoggerMessageProcessor: 

            Something



            Something else

我错过了什么?我已经尝试在拆分之前添加各种不同的转换器(例如 Object to XML as suggested here)但无济于事。

尝试将 xpath 表达式强制为 return 一个节点集:

<splitter expression="#[xpath3('/itm:ItemList/itm:Item', payload, 'NODESET')]"
        doc:name="Splitter" />