Newer Version Available
CRUD-Based Metadata Development
Metadata calls are different from the core, synchronous API calls in these ways.
- Metadata API calls are available in a separate WSDL. To download the WSDL, log into Salesforce, from Setup, enter API in the Quick Find box, then select API and click the Download Metadata WSDL link.
- After logging in, you must send Metadata API calls to the Metadata API endpoint, which has a different URL than SOAP API. Retrieve the metadataServerUrl from the LoginResult returned by your SOAP API login() call. For more information about SOAP API, see the SOAP API Developer Guide.
- Metadata calls are either synchronous or asynchronous. CRUD calls are synchronous in API version 30.0 and later, and similar to the API core calls the results are returned in a single call. In earlier API versions, create, update, and delete are only asynchronous, which means that the results aren’t immediately returned in one call.
- There are synchronous metadata calls that map to the corresponding core SOAP API
synchronous calls.
- createMetadata() maps to the create() SOAP API call.
- updateMetadata() maps to the update() SOAP API call.
- deleteMetadata() maps to the delete() SOAP API call.
Java Sample for CRUD-Based Development with Synchronous Calls
This section guides you through a sample Java client application that uses CRUD-based calls. This sample application performs the following main tasks.
- Uses the MetadataLoginUtil.java class to create a Metadata connection. For more information, see Step 3: Walk Through the Java Sample Code.
- Calls createMetadata() to create a custom object. This call returns the result in one call.
- Inspects the returned SaveResult object to check if the operation succeeded, and if it didn’t, writes the component name, error message, and status code to the output.
Java Sample for CRUD-Based Development with Asynchronous Calls
This section guides you through a sample Java client application that uses asynchronous CRUD-based calls. This sample application performs the following main tasks:
- Uses the MetadataLoginUtil.java class to create a Metadata connection. For more information, see Step 3: Walk Through the Java Sample Code.
- Calls create() to create a
custom object.
Salesforce returns an AsyncResult object for each component you tried to create. The AsyncResult object is updated with status information as the operation moves from a queue to completed or error state.
- Calls checkStatus() in a loop until the status value in AsyncResult indicates that the create operation is completed.
Note the error handling code that follows each API call.