2015-05-12 22 views
2

我的Java代码是:骡DB2 SFDC帐户数据加载

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

回答

1

正如在错误消息中给出的,我没有在列表中包含必须在sfdc中创建/更新帐户的完整字段。 我最后的代码是:

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

骡子的更新流程:

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