Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Salesforce

...

component

...

Available

...

as

...

of

...

Camel

...

2.12

...

This

...

component

...

supports

...

producer

...

and

...

consumer

...

endpoints

...

to

...

communicate

...

with

...

Salesforce

...

using

...

Java

...

DTOs.

...


There

...

is

...

a

...

companion

...

maven

...

plugin

...

Camel

...

Salesforce

...

Plugin

...

that

...

generates

...

these

...

DTOs.

...

Maven

...

users

...

will

...

need

...

to

...

add

...

the

...

following

...

dependency

...

to

...

their

...

pom.xml

...

for

...

this

...

component:

Code Block
xml
xml

{code:xml}
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-salesforce</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
{code}

h3. URI format

URI format

The URI scheme for a salesforce component is as follows

Code Block


The URI scheme for a salesforce component is as follows

{code}
force:topic?options
{code}

You

...

can

...

append

...

query

...

options

...

to

...

the

...

URI

...

in

...

the

...

following

...

format,

...

?option=value&option=value&...

Supported Salesforce APIs

The component supports the following Salesforce APIs

Producer endpoints can use the following APIs. Most of the APIs process one record at a time, the Query API can retrieve multiple Records.

Rest API

  • getVersions - Gets supported Salesforce REST API versions
  • getResources - Gets available Salesforce REST Resource endpoints
  • getGlobalObjects - Gets metadata for all available SObject types
  • getBasicInfo - Gets basic metadata for a specific SObject type
  • getDescription - Gets comprehensive metadata for a specific SObject type
  • getSObject - Gets an SObject using its Salesforce Id
  • createSObject - Creates an SObject
  • updateSObject - Updates an SObject using Id
  • deleteSObject - Deletes an SObject using Id
  • getSObjectWithId - Gets an SObject using an external (user defined) id field
  • upsertSObject - Updates or inserts an SObject using an external id
  • deleteSObjectWithId - Deletes an SObject using an external id
  • query - Runs a Salesforce SOQL query
  • queryMore - Retrieves more results (in case of large number of results) using result link returned from the 'query' API
  • search - Runs a Salesforce SOSL query

For example, the following producer endpoint uses the upsertSObject API, with the sObjectIdName parameter specifying 'Name' as the external id field.
The request message body should be an SObject DTO generated using the maven plugin.
The response message will either be null if an existing record was updated, or CreateSObjectResult with an id of the new record, or a list of errors while creating the new object.

Code Block
}}

h3. Supported Salesforce APIs

The component supports the following Salesforce APIs

Producer endpoints can use the following APIs. Most of the APIs process one record at a time, the Query API can retrieve multiple Records. 

Rest API supported:
* getVersions - Gets supported Salesforce REST API versions
* getResources - Gets available Salesforce REST Resource endpoints
* getGlobalObjects - Gets metadata for all available SObject types
* getBasicInfo - Gets basic metadata for a specific SObject type
* getDescription - Gets comprehensive metadata for a specific SObject type
* getSObject - Gets an SObject using its Salesforce Id
* createSObject - Creates an SObject
* updateSObject - Updates an SObject using Id
* deleteSObject - Deletes an SObject using Id
* getSObjectWithId - Gets an SObject using an external (user defined) id field
* upsertSObject - Updates or inserts an SObject using an external id
* deleteSObjectWithId - Deletes an SObject using an external id
* query - Runs a Salesforce SOQL query
* queryMore - Retrieves more results (in case of large number of results) using result link returned from the 'query' API
* search - Runs a Salesforce SOSL query



h3. Component and endpoint options
{div:class=confluenceTableSmall}
|| Name || Default Value || Description ||
| {{username}} |  | Username for account. This is mandatory. |
| {{password}} |  | Password for account. This is mandatory. |
| {{json}} | {{true}} | Whether to return data in JSON format. If this option is false, then XML is returned in [Atom] format. |
| {{jsonAsMap}} | {{true}} | To transform the JSON from a String to a Map in the message body. |
| {{flatternMap}} | {{true}} | If the JSON Map contains only a single entry, then flattern by storing that single entry value as the message body. |
{div}


h3. Message Headers

The following headers can be used by the producer.

{div:class=confluenceTableSmall}
|| Name || Type || Description ||
| {{CamelNetWeaverCommand}} | {{String}} | *Mandatory*: The command to execute in [MS ADO.Net Data Service|http://msdn.microsoft.com/en-us/library/cc956153.aspx] format. |
{div}

h3. Examples

For example, the following producer endpoint uses the upsertSObject API, with the sObjectIdName parameter specifying 'Name' as the external id field. 
The request message body should be an SObject DTO generated using the maven plugin. 
The response message will either be {{null}} if an existing record was updated, or {{CreateSObjectResult}} with an id of the new record, or a list of errors while creating the new object.
{code}
	...to("force:upsertSObject?sObjectIdName=Name")...
{code}

{include:Endpoint See Also}

Rest Bulk API

Producer endpoints can use the following APIs. All Job data formats, i.e. xml, csv, zip/xml, and zip/csv are supported.
The request and response have to be marshalled/unmarshalled by the route. Usually the request will be some stream source like a CSV file,
and the response may also be saved to a file to be correlated with the request.

  • createJob - Creates a Salesforce Bulk Job
  • getJob - Gets a Job using its Salesforce Id
  • closeJob - Closes a Job
  • abortJob - Aborts a Job
  • createBatch - Submits a Batch within a Bulk Job
  • getBatch - Gets a Batch using Id
  • getAllBatches - Gets all Batches for a Bulk Job Id
  • getRequest - Gets Request data (XML/CSV) for a Batch
  • getResults - Gets the results of the Batch when its complete
  • createBatchQuery - Creates a Batch from an SOQL query
  • getQueryResultIds - Gets a list of Result Ids for a Batch Query
  • getQueryResult - Gets results for a Result Id

For example, the following producer endpoint uses the createBatch API to create a Job Batch.
The in message must contain a body that can be converted into an InputStream (usually UTF-8 CSV or XML content from a file, etc.) and header fields 'jobId' for the Job and 'contentType' for the Job content type, which can be XML, CSV, ZIP_XML or ZIP_CSV. The put message body will contain BatchInfo on success, or throw a SalesforceException on error.

Code Block

	...to("force:createBatchJob")..

Rest Streaming API

Consumer endpoints can use the following sytax for streaming endpoints to receive Salesforce notifications on create/update.

To create and subscribe to a topic

Code Block

	from("force:CamelTestTopic?notifyForFields=ALL&notifyForOperations=ALL&sObjectName=Merchandise__c&updateTopic=true&sObjectQuery=SELECT Id, Name FROM Merchandise__c")...

To subscribe to an existing topic

Code Block

	from("force:CamelTestTopic&sObjectName=Merchandise__c")...
Include Page
CAMEL:Endpoint See Also
CAMEL:Endpoint See Also