mule db2 sfdc账户数据加载

mule db2 sfdc account data loading

我的Java代码是:

public class Db2sfdc {      
    public Map<String, Object> getPayloadData(@Payload String src){     
        HashMap<String, Object> sfdcFields = new HashMap<String, Object>();
        Map<String, Object> payloadMap = new HashMap<String, Object>();
        List<Map<String, Object>> objects = new ArrayList<Map<String,Object>>();
        sfdcFields.put("Client_Alert_Description__c", "Mule interation");
        sfdcFields.put("Client_Status_Reason__c","POC update");
        sfdcFields.put("Credit_Terms__c", "POC Terms");
        objects.add(sfdcFields);
        payloadMap.put("type", "Account");
        payloadMap.put("objects", objects);
        return payloadMap ;
    }

骡子流:

<flow name="db2accountFlow1" doc:name="db2accountFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="db2account" doc:name="HTTP"/>
    <invoke name="sfdcmap" object-ref="db2sfdc" method="getPayloadData" methodArguments="#[message.payload]" methodArgumentTypes="java.lang.String" doc:name="Invoke"/>
    <sfdc:upsert config-ref="Salesforce__Basic_authentication" externalIdFieldName="Client Status" type="Account" doc:name="Salesforce">
        <sfdc:objects ref="#[payload.objects]"/>
    </sfdc:upsert>        
</flow>

浏览器的错误消息:

 Failed to invoke upsert. Message payload is of type: HashMap

控制台错误:

ERROR 2015-05-11 18:58:38,090 [[sfdc].connector.http.mule.default.receiver.04] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: null. Type: class com.sforce.soap.partner.fault.InvalidFieldFault
ERROR 2015-05-11 18:58:38,094 [[sfdc].connector.http.mule.default.receiver.04] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Failed to invoke upsert. Message payload is of type: HashMap
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (com.sforce.soap.partner.fault.InvalidFieldFault)
  sun.reflect.NativeConstructorAccessorImpl:-2 (null)
2. [InvalidFieldFault [ApiQueryFault [ApiFault  exceptionCode='INVALID_FIELD'
 exceptionMessage='No such column 'Client_Alert_Description__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.'
]
 row='-1'
 column='-1'
]
]
 (java.lang.RuntimeException)
  org.mule.modules.salesforce.api.SalesforceExceptionHandlerAdapter:69 (null)
3. Failed to invoke upsert. Message payload is of type: HashMap (org.mule.api.MessagingException)
  org.mule.devkit.processor.DevkitBasedMessageProcessor:128 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
[InvalidFieldFault [ApiQueryFault [ApiFault  exceptionCode='INVALID_FIELD'
 exceptionMessage='No such column 'Client_Alert_Description__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.'
]
 row='-1'
 column='-1'
]
]

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

如错误消息中所示,我没有在列表中包含完整字段,这些字段对于 sfdc 中的 create/update 帐户是必需的。 我的最终代码是:

public List<Map<String, Object>> getPayloadData(@Payload String src){
        Map<String, Object> sfdcFields = new HashMap<String, Object>();
        List<Map<String, Object>> accountList = new ArrayList<Map<String,Object>>();    
        sfdcFields.put("ID", "001m000000In0p5AAB");
        sfdcFields.put("Current_WSE_Count__c", "20");
        accountList.add(sfdcFields);
        return accountList ;
}

更新的 Mule 流:

 <sfdc:update config-ref="Salesforce__Basic_authentication"  type="Account" doc:name="Salesforce">
            <sfdc:objects ref="#[payload]"/>
 </sfdc:update>