在消息Enricher中调用组件以及如何为Message Enricher定义目标值

时间:2017-03-23 17:26:34

标签: mule

我在salesforce上练习mulesoft连接。我正在尝试从salesforce查询帐户,使用Invoke Component执行一些逻辑并更新Salesforce中的帐户名称。请在下面找到XML代码。我调用时出现以下错误..

  

表达式“变量:Fname = __ object_for_enrichment”的执行失败。 (org.mule.api.expression.ExpressionRuntimeException)。

XML:

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8092" doc:name="HTTP Listener Configuration"/>
    <sfdc:config name="Salesforce__Basic_Authentication" username="username" password="*******" securityToken="Token" doc:name="Salesforce: Basic Authentication" url="https://login.salesforce.com/services/Soap/u/38.0">
        <reconnect-forever/>
    </sfdc:config>
    <spring:beans>
        <spring:bean id="Bean" name="UpdateAcc" class="com.pack.salesforceconnect.SFJava"/>
    </spring:beans>
    <flow name="salesforceconnectFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/salesforce" doc:name="HTTP"/>
        <sfdc:query-single config-ref="Salesforce__Basic_Authentication" query="dsql:SELECT Id,Name,ShippingCity FROM Account ORDER BY Name DESC" doc:name="Salesforce"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:input-payload doc:sample="sample_data\Account.dwl"/>
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
    Id: payload.Id,
    Name: payload.Name,
    ShippingCity: payload.ShippingCity
}]]></dw:set-payload>
        </dw:transform-message>
        <enricher source="#[payload.Name]" target="#[Variable:Fname]" doc:name="Message Enricher">
            <invoke name="Invoke" object-ref="UpdateAcc" method="ChangeSCity" methodArguments="#[payload.Name]" metadata:id="id"/>
        </enricher>
        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
[{
    Id: payload.Id,
    Name: variable:FName,
    ShippingCity: payload.ShippingCity
}]]]></dw:set-payload>
        </dw:transform-message>
        <set-payload value="#[payload]" doc:name="Set Payload"/>
    </flow>
</mule>

类别:

package com.pack.salesforceconnect;

public class SFJava {
    public String ChangeSCity(String Fname){
        //String ShippingCity;
        System.out.print("Account Name received : "+Fname);
        if (Fname == null){
         Fname = "New Account";
        }else{
            Fname = "Washington Industries Inc.,";
            }
        System.out.print("Account Name: "+Fname);

        return Fname;
        }

}

1 个答案:

答案 0 :(得分:1)

语法错误..它将是target="#[variable:Fname]"而不是target="#[Variable:Fname]"
或者只是您可以使用target="#[flowVars.Fname]"