【问题标题】:Mule esb and Transform message (wave transform component)Mule esb 和 Transform 消息(波形变换组件)
【发布时间】:2016-07-18 11:52:56
【问题描述】:

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

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

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

<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>

当我在转换之前将记录器记录到有效负载时,两个流程中的记录都是相同的...... 谁能告诉我我做错了什么?

谢谢伊万。

【问题讨论】:

    标签: mule mule-component dataweave


    【解决方案1】:

    由于设置的有效负载缺少 mime 类型,因此使用下面的 xml 会出现错误,我已经测试并且它工作正常。&lt;set-payload value="#[flowVars.OriginalPayload]" doc:name="Set Payload" mimeType="application/json"/&gt;

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-02
      • 1970-01-01
      • 1970-01-01
      • 2015-04-29
      • 1970-01-01
      • 2015-06-06
      相关资源
      最近更新 更多