wso2 esb 在 xml 中丰富文本

wso2 esb enrich text in xml

我正在尝试使用 WSO2 ESB 版本 4.9.0 丰富 XML-Node 的文本。

简单XML:

<enrich>
    <source type="inline">
        <query><where><order.id>0</order.id></where></query>
    </source>
    <target type="body" />
</enrich>

充实:

<enrich>
    <source type="property" property="uri.var.processId" />
    <target action="replace" type="body" xpath="//order.id/text()" />
</enrich>

但是输出看起来像这样:

<query xmlns="http://ws.apache.org/ns/synapse"><where><order.id>0</order.id></where>SOHBSS-000002</query>

当我期待这个时:

<query xmlns="http://ws.apache.org/ns/synapse"><where><order.id>SOHBSS-000002</order.id></where></query>

当我进一步将给定的 XML 简化为 <order.id>0</order.id> 时,来自上面的相同丰富调解器给出了正确的 <order.id xmlns="http://ws.apache.org/ns/synapse">SOHBSS-000002</order.id> 输出。

xpath是不是错了?还是我将 enrich mediator 用于它不适合的用途?

因为 XML 很简单,所以我尽量不使用 XSLT 来进行更改。

在您的第二次充实中,尝试将目标类型从正文替换为自定义:

<enrich>
    <source type="property" property="uri.var.processId" />
    <target action="replace" type="custom" xpath="//order.id/text()" />
</enrich>

我在尝试对带有命名空间的标签执行 xpath 时遇到了一些困难,所以在这里(感谢 Lesrac 对 xmlns 的评论)

<enrich>
    <source type="inline">
        <query namespace="http://www.fadata.bg/Insurance_Messages/v3.0/xml/">
          <where><order.id>0</order.id></where></query>
    </source>
    <target type="body" />
</enrich>
<enrich>
    <source type="property" property="uri.var.processId" />
    <target action="replace" type="custom" xpath="//fadata:order.id/text()"
       xmlns:fadata="http://www.fadata.bg/Insurance_Messages/v3.0/xml/"/>
</enrich>