SlideShare a Scribd company logo
MULE ESB 3.6
CRUD operations on Salesforce using Mule ESB
Objective
 Advantages of using Salesforce connector
 How to performCreate, Read, Update and Delete
operations on Salesforce
Pre-requisites
 Anypoint Studio
 A Salesforce developer account
 A security token for Salesforce
Salesforce Connector
 Salesforce connector allows Mule ESB application to
connect to Salesforce
 It supports data sense which fetches meta data
information about of Salesforce once required
connection details are specified at the connector
 It lists all objects and operations at design time using
data sense and makes development easy and rapid
Steps
 Create a Salesforce developer account
 Create a security token for Salesforce account
 Create a mule application to perform CRUD
operations
How to create Salesforce
developer account
 Sign up for a new account at http://developer.force.com/
How to generate a security
token
 Sign into http://developer.force.com/, click your name in
the upper right corner, then click Setup > My Personal
Information > Reset SecurityToken.Then, click Reset My
SecurityToken. Salesforce sends your security token via
email to your registered email address
Create a mule application to
perform CRUD operations
 Create a property file
 Configure property file in your project
 Add Salesforce connector and configure the
connector details
 Configure a flow
 Run your application
 Create a property file with following details
and place it in mule_home/conf folder
#SF URL
sf_url=https://<your salesforce url>/services/Soap/u/26.0
#SF Username
sf_username=<Your salesforce account name>
#SF Password
sf_password=<Your salesforce account password>
#SF Security Token
sf_security_token=<Your salesforce security token>
Add the property file in
your flow
 Click on global elements tab -> Click on create ->Type in Property
Placeholder in the filter box -> Select Property Placeholder and click
on Ok ->Type in “file:${mule_home}/conf/salesforce-
config.properties” in the location text box and click on Ok
 You should see an XML tag added under your configurationXML as
below
<context:property-placeholder
location="file:${mule_home}/conf/salesforce-config.properties"/>
Add Salesforce connector in
your flow
 Click on global elements tab -> Click on create -> Select
Salesforce and add property as shown below
You need to create 3 java
classes as show below
 CreateContactRequest.java
public class CreateContactRequest implements Callable {
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
HashMap<String,Object> contactSObjectFields = new HashMap<String,Object>();
// sObject is defined as a map
contactSObjectFields.put("FirstName", “YourFirstName");
contactSObjectFields.put("LastName", "YourLastName");
contactSObjectFields.put("MobilePhone", "YourMobileNo");
contactSObjectFields.put("Email", “YourEmail");
// list of sobjects to be created
List<HashMap<String,Object>> objects = new ArrayList<HashMap<String,Object>>();
objects.add(contactSObjectFields);
// map that will be placed as payload
HashMap<String,Object> payload = new HashMap<String,Object>();
payload.put("type", "Contact");
payload.put("objects", objects);
return payload;
}
}
 UpdateContactRequest.java
public class UpdateContactRequest implements Callable {
@Override
publicObject onCall(MuleEventContext eventContext) throws Exception {
HashMap<String,Object> contactSObjectFields = new HashMap<String,Object>();
MuleMessage muleMessage = eventContext.getMessage();
contactSObjectFields.put("FirstName", “YourModifiedFirstName");
contactSObjectFields.put("LastName", "YourModifiedLastName");
contactSObjectFields.put("MobilePhone", "YourModifiedMobileNo");
contactSObjectFields.put("Email", “YourModifiedEmail");
contactSObjectFields.put("Id", muleMessage.getProperty("sObjectId", PropertyScope.SESSION));
// map that will be placed as payload
HashMap<String,Object> payload = new HashMap<String,Object>();
payload.put("type", "Contact");
payload.put("object", contactSObjectFields);
return payload;
}
}
 CreateContactResponseProcessor.java
public class CreateContactResponseProcessor implements Callable {
@SuppressWarnings("unchecked")
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
AcknowledgementType ack = new AcknowledgementType();
MuleMessage message = eventContext.getMessage();
System.out.println(message.toString());
// get the message payload
List<SaveResult> saveResults = (List<SaveResult>) message.getPayload();
Iterator<SaveResult> iter = saveResults.iterator();
SaveResult saveResult = iter.next();
ack.setMessageID(saveResult.getId());
if(saveResult.getSuccess())
ack.setStatus("Success");
else
ack.setStatus("Success");
System.out.println(ack);
return ack.getMessageID();
}
}
Create a mule flow with as
show below
The flow configuration will look should
look like as follows
<context:property-placeholder location="file:${mule_home}/conf/salesforce-config.properties"/>
<sfdc:config name="Salesforce" username="${sf_username}" password="${sf_password}" securityToken="${sf_security_token}" url="${sf_url}" doc:name="Salesforce">
<sfdc:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</sfdc:config>
<flow name="CreateContact" doc:name="CreateContact">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="1001" path="SFDC_CRUD" doc:name="HTTP_Inbound"/>
<component class="com.sfdc.requestresponse.processor.CreateContactRequest"doc:name="CreateContactRequest"/>
<logger message="Salesforce Request----&gt; #[payload]" level="INFO" doc:name="LogSalesforceRequest"/>
<sfdc:create config-ref="Salesforce" doc:name="CreateSalesforceContact" type="#[payload.type]">
<sfdc:objects ref="#[payload.objects]"/>
</sfdc:create>
<logger message="SFDC output: ------ #[payload]" level="INFO" doc:name="LogSalesforceResponse"/>
<component class="com.sfdc.requestresponse.processor.CreateContactResponseProcessor" doc:name="CreateContactSFResponseProcessor"/>
<message-properties-transformer overwrite="true" scope="session" doc:name="StoreContactId">
<add-message-property key="sObjectId" value="#[payload]"/>
</message-properties-transformer>
<flow-ref name="QueryContact" doc:name="GoToReadContactFlow"/>
</flow>
<flow name="QueryContact" doc:name="QueryContact">
<logger level="INFO" doc:name="LogSalesforceReadContactRequest"/>
<sfdc:query config-ref="Salesforce" query="SELECT Id,Name,BillingStreet, BillingCity,BillingState,BillingPostalCode,BillingCountry FROM Account WHERE Id = '#[sessionVars.sObjectId]'" doc:name="ReadSalesforceContact"/>
<logger level="INFO" doc:name="LogSalesforceReadContactResponse" message="Query Output: #[payload]"/>
<flow-ref name="UpdateContact" doc:name="GoToUpdateContactFlow"/>
</flow>
<flow name="UpdateContact" doc:name="UpdateContact">
<component class="com.sfdc.requestresponse.processor.UpdateContactRequest" doc:name="UpdateContactRequest"/>
<logger message="Update Request----&gt; #[payload]" level="INFO" doc:name="LogUpdateContactSalesforceRequest"/>
<sfdc:update-single config-ref="Salesforce" type="#[payload.type]" doc:name="UpdateSalesforceContact">
<sfdc:object ref="#[payload.object]"/>
</sfdc:update-single>
<logger message="Update Output----&gt; #[payload]" level="INFO" doc:name="LogContactUpdated"/>
<flow-ref name="ReadContactAgain" doc:name="GoToReadContactFlow"/>
</flow>
<flow name="ReadContactAgain" doc:name="ReadContactAgain">
<logger level="INFO" doc:name="LogSalesforceReadContactRequest"/>
<sfdc:query config-ref="Salesforce" query="SELECT Id,Name,BillingStreet, BillingCity,BillingState,BillingPostalCode,BillingCountry FROM Account WHERE Id = '#[sessionVars.sObjectId]'" doc:name="ReadSalesforceContact"/>
<logger level="INFO" doc:name="LogSalesforceReadContactResponse" message="Query Output: #[payload]"/>
<flow-ref name="DeleteContact" doc:name="GoToDeleteContactFlow"/>
</flow>
<flow name="DeleteContact" doc:name="DeleteContact">
<sfdc:delete config-ref="Salesforce" doc:name="DeleteSalesforceContact">
<sfdc:ids>
<sfdc:id>#[sessionVars.sObjectId]</sfdc:id>
</sfdc:ids>
</sfdc:delete>
<logger level="INFO" doc:name="LogDeleteContactResponse" message="Delete Output-----&gt;#[payload]"/>
<set-payload value="&quot;CRUD Operations executed successfully. Please check the logs for details&quot;" doc:name="Set Payload"/>
</flow>
 Now you can run the application and hit the http URL configured in
your application in browser
 It should create a contact, read the values, update the contact, read
the value and finally delate the contact from Salesforce.
 You can delete the last flow reference for delete contact if you like to
see the contact in Salesforce for your testing
 Details of the contact creation to deletion can be observed in logs
Extract from the logs
INFO 2015-03-21 20:01:39,730 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Salesforce
Request----> {type=Contact, objects=[{Email=xyz@abc.com, FirstName=Rupesh, MobilePhone=078000000, LastName=Sinha}]}
INFO 2015-03-21 20:01:41,605 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: SFDC
output: ------ [[SaveResult errors='{[0]}'
id='003L000000YhRS5IAN'
success='true'
]
]
Status: Success, Id: 003L000000YhRS5IAN
INFO 2015-03-21 20:01:42,069 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Query
Output: []
INFO 2015-03-21 20:01:42,073 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Update
Request----> {object={Email=xyz@abc.com, FirstName=Rupesh_Changed, Id=003L000000YhRS5IAN, MobilePhone=078000000,
LastName=Sinha_Changed}, type=Contact}
INFO 2015-03-21 20:01:42,883 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Update
Output----> [SaveResult errors='{[0]}'
id='003L000000YhRS5IAN'
success='true'
]
INFO 2015-03-21 20:01:43,254 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Query
Output: []
INFO 2015-03-21 20:01:44,053 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Delete
Output-----> [[DeleteResult errors='{[0]}'
id='003L000000YhRS5IAN'
success='true'
]
]
Thanks for watching

More Related Content

What's hot

Dataweave 160103180124
Dataweave 160103180124Dataweave 160103180124
Dataweave 160103180124
vijay dhanakodi
 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notification
Priyobroto Ghosh (Mule ESB Certified)
 
Mule data weave
Mule data weaveMule data weave
Mule data weave
D.Rajesh Kumar
 
How to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis moduleHow to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis module
Priyobroto Ghosh (Mule ESB Certified)
 
Mule with jdbc(my sql)
Mule with jdbc(my sql)Mule with jdbc(my sql)
Mule with jdbc(my sql)
charan teja R
 
Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400
himajareddys
 
Dropbox connector Mule ESB Integration
Dropbox connector Mule ESB IntegrationDropbox connector Mule ESB Integration
Dropbox connector Mule ESB Integration
AnilKumar Etagowni
 
Dataweave
Dataweave Dataweave
Dataweave
Praneethchampion
 
Junit in mule demo
Junit in mule demoJunit in mule demo
Junit in mule demo
Sudha Ch
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
AnilKumar Etagowni
 
Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
Antonio Pellegrino
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
Praneethchampion
 
Automatic documentation with mule
Automatic documentation with muleAutomatic documentation with mule
Automatic documentation with mule
F K
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
akashdprajapati
 
Mule ESB SMTP Connector Integration
Mule ESB SMTP Connector  IntegrationMule ESB SMTP Connector  Integration
Mule ESB SMTP Connector Integration
AnilKumar Etagowni
 

What's hot (15)

Dataweave 160103180124
Dataweave 160103180124Dataweave 160103180124
Dataweave 160103180124
 
Refreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notificationRefreshing mule cache using oracle database change notification
Refreshing mule cache using oracle database change notification
 
Mule data weave
Mule data weaveMule data weave
Mule data weave
 
How to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis moduleHow to connect redis and mule esb using spring data redis module
How to connect redis and mule esb using spring data redis module
 
Mule with jdbc(my sql)
Mule with jdbc(my sql)Mule with jdbc(my sql)
Mule with jdbc(my sql)
 
Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400
 
Dropbox connector Mule ESB Integration
Dropbox connector Mule ESB IntegrationDropbox connector Mule ESB Integration
Dropbox connector Mule ESB Integration
 
Dataweave
Dataweave Dataweave
Dataweave
 
Junit in mule demo
Junit in mule demoJunit in mule demo
Junit in mule demo
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 
Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Automatic documentation with mule
Automatic documentation with muleAutomatic documentation with mule
Automatic documentation with mule
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
 
Mule ESB SMTP Connector Integration
Mule ESB SMTP Connector  IntegrationMule ESB SMTP Connector  Integration
Mule ESB SMTP Connector Integration
 

Similar to mule salesforce

mule salesforce
mule salesforcemule salesforce
mule salesforce
Khasim Saheb
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
Son Nguyen
 
Salesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on TrainingSalesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on Training
Sunil kumar
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
Claims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .newClaims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .new
RavikantChaturvedi
 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command line
Cyrille Coeurjoly
 
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
Hasnain Iqbal
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
Katy Slemon
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectors
rtretola
 
Java script -23jan2015
Java script -23jan2015Java script -23jan2015
Java script -23jan2015
Sasidhar Kothuru
 
Toms introtospring mvc
Toms introtospring mvcToms introtospring mvc
Toms introtospring mvcGuo Albert
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6Usman Zafar Malik
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
Max Klymyshyn
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesNCCOMMS
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
Son Nguyen
 
How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...
Priyobroto Ghosh (Mule ESB Certified)
 

Similar to mule salesforce (20)

mule salesforce
mule salesforcemule salesforce
mule salesforce
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
 
Salesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on TrainingSalesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on Training
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Claims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .newClaims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .new
 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command line
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectors
 
Java script -23jan2015
Java script -23jan2015Java script -23jan2015
Java script -23jan2015
 
Toms introtospring mvc
Toms introtospring mvcToms introtospring mvc
Toms introtospring mvc
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Jsf
JsfJsf
Jsf
 
SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
 
How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...
 

More from F K

WebServices introduction in Mule
WebServices introduction in MuleWebServices introduction in Mule
WebServices introduction in Mule
F K
 
Testing soapui
Testing soapuiTesting soapui
Testing soapui
F K
 
Java For Begineers
Java For BegineersJava For Begineers
Java For Begineers
F K
 
Vm component
Vm componentVm component
Vm component
F K
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mule
F K
 
Quartz component
Quartz componentQuartz component
Quartz component
F K
 
Mule management console installation
Mule management console installation Mule management console installation
Mule management console installation
F K
 
Mule esb made system integration easy
Mule esb made system integration easy Mule esb made system integration easy
Mule esb made system integration easy
F K
 
Message properties component
Message properties componentMessage properties component
Message properties component
F K
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
F K
 
Install sonarqube plugin in anypoint
Install sonarqube plugin in anypoint Install sonarqube plugin in anypoint
Install sonarqube plugin in anypoint
F K
 
Commit a project in svn using svn plugin in anypoint studio
Commit a project in svn using svn plugin in anypoint studioCommit a project in svn using svn plugin in anypoint studio
Commit a project in svn using svn plugin in anypoint studio
F K
 
Github plugin setup in anypoint studio
Github plugin setup in anypoint studio Github plugin setup in anypoint studio
Github plugin setup in anypoint studio
F K
 
For each component
For each component For each component
For each component
F K
 
Filter expression
Filter expression Filter expression
Filter expression
F K
 
File component
File component File component
File component
F K
 
Database component
Database component Database component
Database component
F K
 
Choice component
Choice component Choice component
Choice component
F K
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
F K
 
Mule esb Data Weave
Mule esb Data WeaveMule esb Data Weave
Mule esb Data Weave
F K
 

More from F K (20)

WebServices introduction in Mule
WebServices introduction in MuleWebServices introduction in Mule
WebServices introduction in Mule
 
Testing soapui
Testing soapuiTesting soapui
Testing soapui
 
Java For Begineers
Java For BegineersJava For Begineers
Java For Begineers
 
Vm component
Vm componentVm component
Vm component
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mule
 
Quartz component
Quartz componentQuartz component
Quartz component
 
Mule management console installation
Mule management console installation Mule management console installation
Mule management console installation
 
Mule esb made system integration easy
Mule esb made system integration easy Mule esb made system integration easy
Mule esb made system integration easy
 
Message properties component
Message properties componentMessage properties component
Message properties component
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Install sonarqube plugin in anypoint
Install sonarqube plugin in anypoint Install sonarqube plugin in anypoint
Install sonarqube plugin in anypoint
 
Commit a project in svn using svn plugin in anypoint studio
Commit a project in svn using svn plugin in anypoint studioCommit a project in svn using svn plugin in anypoint studio
Commit a project in svn using svn plugin in anypoint studio
 
Github plugin setup in anypoint studio
Github plugin setup in anypoint studio Github plugin setup in anypoint studio
Github plugin setup in anypoint studio
 
For each component
For each component For each component
For each component
 
Filter expression
Filter expression Filter expression
Filter expression
 
File component
File component File component
File component
 
Database component
Database component Database component
Database component
 
Choice component
Choice component Choice component
Choice component
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule esb Data Weave
Mule esb Data WeaveMule esb Data Weave
Mule esb Data Weave
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

mule salesforce

  • 1. MULE ESB 3.6 CRUD operations on Salesforce using Mule ESB
  • 2. Objective  Advantages of using Salesforce connector  How to performCreate, Read, Update and Delete operations on Salesforce
  • 3. Pre-requisites  Anypoint Studio  A Salesforce developer account  A security token for Salesforce
  • 4. Salesforce Connector  Salesforce connector allows Mule ESB application to connect to Salesforce  It supports data sense which fetches meta data information about of Salesforce once required connection details are specified at the connector  It lists all objects and operations at design time using data sense and makes development easy and rapid
  • 5. Steps  Create a Salesforce developer account  Create a security token for Salesforce account  Create a mule application to perform CRUD operations
  • 6. How to create Salesforce developer account  Sign up for a new account at http://developer.force.com/
  • 7. How to generate a security token  Sign into http://developer.force.com/, click your name in the upper right corner, then click Setup > My Personal Information > Reset SecurityToken.Then, click Reset My SecurityToken. Salesforce sends your security token via email to your registered email address
  • 8. Create a mule application to perform CRUD operations  Create a property file  Configure property file in your project  Add Salesforce connector and configure the connector details  Configure a flow  Run your application
  • 9.  Create a property file with following details and place it in mule_home/conf folder #SF URL sf_url=https://<your salesforce url>/services/Soap/u/26.0 #SF Username sf_username=<Your salesforce account name> #SF Password sf_password=<Your salesforce account password> #SF Security Token sf_security_token=<Your salesforce security token>
  • 10. Add the property file in your flow  Click on global elements tab -> Click on create ->Type in Property Placeholder in the filter box -> Select Property Placeholder and click on Ok ->Type in “file:${mule_home}/conf/salesforce- config.properties” in the location text box and click on Ok  You should see an XML tag added under your configurationXML as below <context:property-placeholder location="file:${mule_home}/conf/salesforce-config.properties"/>
  • 11. Add Salesforce connector in your flow  Click on global elements tab -> Click on create -> Select Salesforce and add property as shown below
  • 12. You need to create 3 java classes as show below  CreateContactRequest.java public class CreateContactRequest implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { HashMap<String,Object> contactSObjectFields = new HashMap<String,Object>(); // sObject is defined as a map contactSObjectFields.put("FirstName", “YourFirstName"); contactSObjectFields.put("LastName", "YourLastName"); contactSObjectFields.put("MobilePhone", "YourMobileNo"); contactSObjectFields.put("Email", “YourEmail"); // list of sobjects to be created List<HashMap<String,Object>> objects = new ArrayList<HashMap<String,Object>>(); objects.add(contactSObjectFields); // map that will be placed as payload HashMap<String,Object> payload = new HashMap<String,Object>(); payload.put("type", "Contact"); payload.put("objects", objects); return payload; } }
  • 13.  UpdateContactRequest.java public class UpdateContactRequest implements Callable { @Override publicObject onCall(MuleEventContext eventContext) throws Exception { HashMap<String,Object> contactSObjectFields = new HashMap<String,Object>(); MuleMessage muleMessage = eventContext.getMessage(); contactSObjectFields.put("FirstName", “YourModifiedFirstName"); contactSObjectFields.put("LastName", "YourModifiedLastName"); contactSObjectFields.put("MobilePhone", "YourModifiedMobileNo"); contactSObjectFields.put("Email", “YourModifiedEmail"); contactSObjectFields.put("Id", muleMessage.getProperty("sObjectId", PropertyScope.SESSION)); // map that will be placed as payload HashMap<String,Object> payload = new HashMap<String,Object>(); payload.put("type", "Contact"); payload.put("object", contactSObjectFields); return payload; } }
  • 14.  CreateContactResponseProcessor.java public class CreateContactResponseProcessor implements Callable { @SuppressWarnings("unchecked") @Override public Object onCall(MuleEventContext eventContext) throws Exception { AcknowledgementType ack = new AcknowledgementType(); MuleMessage message = eventContext.getMessage(); System.out.println(message.toString()); // get the message payload List<SaveResult> saveResults = (List<SaveResult>) message.getPayload(); Iterator<SaveResult> iter = saveResults.iterator(); SaveResult saveResult = iter.next(); ack.setMessageID(saveResult.getId()); if(saveResult.getSuccess()) ack.setStatus("Success"); else ack.setStatus("Success"); System.out.println(ack); return ack.getMessageID(); } }
  • 15. Create a mule flow with as show below
  • 16. The flow configuration will look should look like as follows <context:property-placeholder location="file:${mule_home}/conf/salesforce-config.properties"/> <sfdc:config name="Salesforce" username="${sf_username}" password="${sf_password}" securityToken="${sf_security_token}" url="${sf_url}" doc:name="Salesforce"> <sfdc:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/> </sfdc:config> <flow name="CreateContact" doc:name="CreateContact"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="1001" path="SFDC_CRUD" doc:name="HTTP_Inbound"/> <component class="com.sfdc.requestresponse.processor.CreateContactRequest"doc:name="CreateContactRequest"/> <logger message="Salesforce Request----&gt; #[payload]" level="INFO" doc:name="LogSalesforceRequest"/> <sfdc:create config-ref="Salesforce" doc:name="CreateSalesforceContact" type="#[payload.type]"> <sfdc:objects ref="#[payload.objects]"/> </sfdc:create> <logger message="SFDC output: ------ #[payload]" level="INFO" doc:name="LogSalesforceResponse"/> <component class="com.sfdc.requestresponse.processor.CreateContactResponseProcessor" doc:name="CreateContactSFResponseProcessor"/> <message-properties-transformer overwrite="true" scope="session" doc:name="StoreContactId"> <add-message-property key="sObjectId" value="#[payload]"/> </message-properties-transformer> <flow-ref name="QueryContact" doc:name="GoToReadContactFlow"/> </flow> <flow name="QueryContact" doc:name="QueryContact"> <logger level="INFO" doc:name="LogSalesforceReadContactRequest"/> <sfdc:query config-ref="Salesforce" query="SELECT Id,Name,BillingStreet, BillingCity,BillingState,BillingPostalCode,BillingCountry FROM Account WHERE Id = '#[sessionVars.sObjectId]'" doc:name="ReadSalesforceContact"/> <logger level="INFO" doc:name="LogSalesforceReadContactResponse" message="Query Output: #[payload]"/> <flow-ref name="UpdateContact" doc:name="GoToUpdateContactFlow"/> </flow> <flow name="UpdateContact" doc:name="UpdateContact"> <component class="com.sfdc.requestresponse.processor.UpdateContactRequest" doc:name="UpdateContactRequest"/> <logger message="Update Request----&gt; #[payload]" level="INFO" doc:name="LogUpdateContactSalesforceRequest"/> <sfdc:update-single config-ref="Salesforce" type="#[payload.type]" doc:name="UpdateSalesforceContact"> <sfdc:object ref="#[payload.object]"/> </sfdc:update-single> <logger message="Update Output----&gt; #[payload]" level="INFO" doc:name="LogContactUpdated"/> <flow-ref name="ReadContactAgain" doc:name="GoToReadContactFlow"/> </flow> <flow name="ReadContactAgain" doc:name="ReadContactAgain"> <logger level="INFO" doc:name="LogSalesforceReadContactRequest"/> <sfdc:query config-ref="Salesforce" query="SELECT Id,Name,BillingStreet, BillingCity,BillingState,BillingPostalCode,BillingCountry FROM Account WHERE Id = '#[sessionVars.sObjectId]'" doc:name="ReadSalesforceContact"/> <logger level="INFO" doc:name="LogSalesforceReadContactResponse" message="Query Output: #[payload]"/> <flow-ref name="DeleteContact" doc:name="GoToDeleteContactFlow"/> </flow> <flow name="DeleteContact" doc:name="DeleteContact"> <sfdc:delete config-ref="Salesforce" doc:name="DeleteSalesforceContact"> <sfdc:ids> <sfdc:id>#[sessionVars.sObjectId]</sfdc:id> </sfdc:ids> </sfdc:delete> <logger level="INFO" doc:name="LogDeleteContactResponse" message="Delete Output-----&gt;#[payload]"/> <set-payload value="&quot;CRUD Operations executed successfully. Please check the logs for details&quot;" doc:name="Set Payload"/> </flow>
  • 17.  Now you can run the application and hit the http URL configured in your application in browser  It should create a contact, read the values, update the contact, read the value and finally delate the contact from Salesforce.  You can delete the last flow reference for delete contact if you like to see the contact in Salesforce for your testing  Details of the contact creation to deletion can be observed in logs
  • 18. Extract from the logs INFO 2015-03-21 20:01:39,730 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Salesforce Request----> {type=Contact, objects=[{Email=xyz@abc.com, FirstName=Rupesh, MobilePhone=078000000, LastName=Sinha}]} INFO 2015-03-21 20:01:41,605 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: SFDC output: ------ [[SaveResult errors='{[0]}' id='003L000000YhRS5IAN' success='true' ] ] Status: Success, Id: 003L000000YhRS5IAN INFO 2015-03-21 20:01:42,069 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Query Output: [] INFO 2015-03-21 20:01:42,073 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Update Request----> {object={Email=xyz@abc.com, FirstName=Rupesh_Changed, Id=003L000000YhRS5IAN, MobilePhone=078000000, LastName=Sinha_Changed}, type=Contact} INFO 2015-03-21 20:01:42,883 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Update Output----> [SaveResult errors='{[0]}' id='003L000000YhRS5IAN' success='true' ] INFO 2015-03-21 20:01:43,254 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Query Output: [] INFO 2015-03-21 20:01:44,053 [[sfdc_connector].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Delete Output-----> [[DeleteResult errors='{[0]}' id='003L000000YhRS5IAN' success='true' ] ]