Mule esb和Transform message(wave transform组件)

Mule esb and Transform message (wave transform component)

我在使用我不理解的转换消息组件和 mule ESB 时遇到问题。 我有一个工作正常的简单流程,开始时它是 Http 端点,最后它是 Transform 消息组件,将一个 JSON 转换为另一个

现在,当我尝试在将消息转换为变量之前存储负载,然后将负载设置为该变量时,转换消息组件出现异常: 类型不匹配 找到:名称,:字符串 必需:名称,:对象(com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException) com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode:65(空)

下面是有效的流程,下面是无效的流程。 有效的流程:

<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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" 
    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/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" doc:name="HTTP Listener Configuration"/>
    <flow name="testFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <dw:transform-message metadata:id="b8a77df6-4692-4c52-b572-b6a175e7467e" doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
    id: payload.transfer-id,
    created-record-status: 'accepter'
}]]></dw:set-payload>
        </dw:transform-message>
    </flow>
</mule>

无效的流程>

<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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" 
    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/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" doc:name="HTTP Listener Configuration"/>
    <flow name="testFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <set-variable variableName="OriginalPayload" value="#[payload]" doc:name="Variable"/>
        <set-payload value="#[flowVars.OriginalPayload]" doc:name="Set Payload"/>
        <dw:transform-message metadata:id="b8a77df6-4692-4c52-b572-b6a175e7467e" doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
    id: payload.transfer-id,
    created-record-status: 'accepter'
}]]></dw:set-payload>
        </dw:transform-message>
    </flow>
</mule>

当我在转换前将记录器用于记录有效载荷时,这在两个流程中都是相同的.... 有人可以告诉我我做错了什么吗?

谢谢伊万。

由于设置的有效负载缺少 mime 类型,您使用下面的 xml 时收到错误消息,我已经测试并且工作正常。<set-payload value="#[flowVars.OriginalPayload]" doc:name="Set Payload" mimeType="application/json"/>

<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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" 
    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/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
    <http:listener-config name="HTTP_Listener_Confi" host="localhost" port="8085" doc:name="HTTP Listener Configuration"/>
    <flow name="testFlow">
        <http:listener config-ref="HTTP_Listener_Confi" path="/test" doc:name="HTTP"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <logger message="#[payload]" level="INFO" doc:name="Logger"/>
        <set-variable variableName="OriginalPayload" value="#[payload]" doc:name="Variable"/>
        <set-payload value="#[flowVars.OriginalPayload]" doc:name="Set Payload" mimeType="application/json"/>
        <dw:transform-message metadata:id="b8a77df6-4692-4c52-b572-b6a175e7467e" doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
    id: payload.transfer-id,
    created-record-status: 'accepter'
}]]></dw:set-payload>
        </dw:transform-message>
    </flow>
</mule>