0

当我尝试使用 CRUD Matadata API 在 Salesforce 中创建自定义对象时,出现以下异常。

     com.sforce.ws.SoapFaultException: Must specify a {http://www.w3.org/2001/XMLSchema-instance}
 type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element
        at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:205)
        at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:149)
        at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:98)
        at com.sforce.soap.metadata.MetadataConnection.create(MetadataConnection.java:273)
        at com.sfo.service.SalesforceObjectBootstrap.createCustomObject(SalesforceObjectBootstrap.java:226)

我正在使用此链接中的代码,我唯一更改的是自定义对象的名称 http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_calls_intro.htm

这一步出现异常

AsyncResult[] asyncResults = metadataConnection.create(new CustomObject[]{customObject});

调用上述 create 方法之前的 Custom 对象具有以下参数值。

[CustomObject [Metadata  fullName='lead_5273_custom_reg__c'
]
 actionOverrides='{[0]}'
 articleTypeChannelDisplay='null'
 businessProcesses='{[0]}'
 customHelp='hey there help me'
 customHelpPage='null'
 customSettingsType='null'
 customSettingsVisibility='null'
 deploymentStatus='Deployed'
 deprecated='false'
 description='Created from backend Webcast API : Lead 5273 Custom Reg'
 enableActivities='false'
 enableDivisions='false'
 enableEnhancedLookup='false'
 enableFeeds='false'
 enableHistory='false'
 enableReports='false'
 fieldSets='{[0]}'
 fields='{[0]}'
 gender='null'
 household='false'
 label='Lead 5273 Custom Reg'
 listViews='{[0]}'
 nameField='[CustomField [Metadata  fullName='lead_5273_custom_reg__c'
]
 caseSensitive='false'
 customDataType='null'
 defaultValue='null'
 deleteConstraint='null'
 deprecated='false'
 description='field name for a metadata custom object'
 displayFormat='null'
 escapeMarkup='false'
 externalDeveloperName='null'
 externalId='false'
 formula='null'
 formulaTreatBlanksAs='null'
 inlineHelpText='null'
 label='Lead 5273 Custom Reg'
 length='0'
 maskChar='null'
 maskType='null'
 picklist='null'
 populateExistingRows='false'
 precision='0'
 referenceTo='null'
 relationshipLabel='null'
 relationshipName='null'
 relationshipOrder='0'
 reparentableMasterDetail='false'
 required='false'
 restrictedAdminField='false'
 scale='0'
 startingNumber='0'
 stripMarkup='false'
 summarizedField='null'
 summaryFilterItems='{[0]}'
 summaryForeignKey='null'
 summaryOperation='null'
 trackFeedHistory='false'
 trackHistory='false'
 type='Text'
 unique='false'
 visibleLines='0'
 writeRequiresMasterRead='false'
]
'
 namedFilters='{[0]}'
 pluralLabel='Lead 5273 Custom Regs'
 recordTypeTrackFeedHistory='false'
 recordTypeTrackHistory='false'
 recordTypes='{[0]}'
 searchLayouts='null'
 sharingModel='ReadWrite'
 sharingReasons='{[0]}'
 sharingRecalculations='{[0]}'
 startsWith='null'
 validationRules='{[0]}'
 webLinks='{[0]}'
]

我使用这里提到的方法来生成 WSDL 文件及其 java 框架。 http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_quickstart.htm#topic-title-sample-code

我的代码与上面提供的示例完全匹配。我只是复制粘贴了整个东西。

I found this link, which mentioned the same exception. But this link is relating to creating a Folder. http://boards.developerforce.com/t5/Java-Development/Metadata-API-errors-Must-specify-a-type-attribute-value-for-the/td-p/175253

Please let me know how to solve this problem.

4

1 回答 1

1

I've not played with this myself, but from the looks of the exception, the MetaData block here:

[CustomObject [Metadata  fullName='lead_5273_custom_reg__c']

needs to contain the object type, which I'm assuming in this case is CustomObject__c (all custom objects have the __c suffix), so maybe try the following:

[CustomObject [Metadata  fullName='lead_5273_custom_reg__c' type='CustomObject__c']

Unless of course, fullname is actually the object name, which could be a possibility.

于 2012-08-21T10:21:54.373 回答