SlideShare a Scribd company logo
Mule ESB 3.6
CRUD operations on Salesforce using
Mule ESB
Objective
– Advantages of using Salesforce connector
– How to perform Create, 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 Security Token. Then, click Reset My
Security Token. 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 configuration XML 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
public Object 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
Ad

More Related Content

What's hot (17)

Integration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESBIntegration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESB
Rupesh Sinha
 
Integration with Sercice-Now using Mule ESB
Integration with Sercice-Now using Mule ESBIntegration with Sercice-Now using Mule ESB
Integration with Sercice-Now using Mule ESB
Sanjeet Pandey
 
Velocity in Mule
Velocity in MuleVelocity in Mule
Velocity in Mule
Mohammed246
 
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)
 
Generating Documentation for Mule ESB Application
Generating Documentation for Mule ESB ApplicationGenerating Documentation for Mule ESB Application
Generating Documentation for Mule ESB Application
Rupesh Sinha
 
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
Anand kalla
 
Mule maven
Mule mavenMule maven
Mule maven
JavierMarRas
 
Mule esb 3.8
Mule esb 3.8Mule esb 3.8
Mule esb 3.8
himajareddys
 
Mule Microsoft Dynamics AX 2012 Connector
Mule Microsoft Dynamics AX 2012 ConnectorMule Microsoft Dynamics AX 2012 Connector
Mule Microsoft Dynamics AX 2012 Connector
Ankush Sharma
 
Mule velocity
Mule velocityMule velocity
Mule velocity
Praneethchampion
 
Mule
MuleMule
Mule
F K
 
Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
Antonio Pellegrino
 
Automatic documentation with mule
Automatic documentation with muleAutomatic documentation with mule
Automatic documentation with mule
F K
 
Create Account in Salesforce using Mule ESB
Create Account in Salesforce using Mule ESBCreate Account in Salesforce using Mule ESB
Create Account in Salesforce using Mule ESB
Sanjeet Pandey
 
Mule testing
Mule   testingMule   testing
Mule testing
Sindhu VL
 
Mule reference
Mule referenceMule reference
Mule reference
himajareddys
 
Oa Framework Tutorial
Oa Framework TutorialOa Framework Tutorial
Oa Framework Tutorial
nolimit797
 
Integration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESBIntegration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESB
Rupesh Sinha
 
Integration with Sercice-Now using Mule ESB
Integration with Sercice-Now using Mule ESBIntegration with Sercice-Now using Mule ESB
Integration with Sercice-Now using Mule ESB
Sanjeet Pandey
 
Velocity in Mule
Velocity in MuleVelocity in Mule
Velocity in Mule
Mohammed246
 
Generating Documentation for Mule ESB Application
Generating Documentation for Mule ESB ApplicationGenerating Documentation for Mule ESB Application
Generating Documentation for Mule ESB Application
Rupesh Sinha
 
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
Anand kalla
 
Mule Microsoft Dynamics AX 2012 Connector
Mule Microsoft Dynamics AX 2012 ConnectorMule Microsoft Dynamics AX 2012 Connector
Mule Microsoft Dynamics AX 2012 Connector
Ankush Sharma
 
Mule
MuleMule
Mule
F K
 
Automatic documentation with mule
Automatic documentation with muleAutomatic documentation with mule
Automatic documentation with mule
F K
 
Create Account in Salesforce using Mule ESB
Create Account in Salesforce using Mule ESBCreate Account in Salesforce using Mule ESB
Create Account in Salesforce using Mule ESB
Sanjeet Pandey
 
Mule testing
Mule   testingMule   testing
Mule testing
Sindhu VL
 
Oa Framework Tutorial
Oa Framework TutorialOa Framework Tutorial
Oa Framework Tutorial
nolimit797
 

Similar to Mule using Salesforce (20)

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
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
Son Nguyen
 
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
 
Toms introtospring mvc
Toms introtospring mvcToms introtospring mvc
Toms introtospring mvc
Guo Albert
 
SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6
Usman Zafar Malik
 
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
Kiril Iliev
 
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
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
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
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
SPTechCon
 
Meetup bangalore aug31st2019
Meetup bangalore aug31st2019Meetup bangalore aug31st2019
Meetup bangalore aug31st2019
D.Rajesh Kumar
 
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
 
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise securityMuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
akashdprajapati
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
NCCOMMS
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
Vivek K. Singh
 
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
 
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)
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
Aren Zomorodian
 
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
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
Son Nguyen
 
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
 
Toms introtospring mvc
Toms introtospring mvcToms introtospring mvc
Toms introtospring mvc
Guo Albert
 
SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6SharePoint 2010 Training Session 6
SharePoint 2010 Training Session 6
Usman Zafar Malik
 
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
Kiril Iliev
 
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
 
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
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
SPTechCon
 
Meetup bangalore aug31st2019
Meetup bangalore aug31st2019Meetup bangalore aug31st2019
Meetup bangalore aug31st2019
D.Rajesh Kumar
 
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
 
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise securityMuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
akashdprajapati
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
NCCOMMS
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
 
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
 
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)
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
Aren Zomorodian
 
Ad

More from Khasim Cise (12)

Scatter gather in mule
Scatter gather in muleScatter gather in mule
Scatter gather in mule
Khasim Cise
 
Java
JavaJava
Java
Khasim Cise
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
Khasim Cise
 
Java
JavaJava
Java
Khasim Cise
 
ESB introduction using Mule
ESB introduction using MuleESB introduction using Mule
ESB introduction using Mule
Khasim Cise
 
Mule Fundamentals
Mule FundamentalsMule Fundamentals
Mule Fundamentals
Khasim Cise
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Khasim Cise
 
Mule ESB
Mule ESBMule ESB
Mule ESB
Khasim Cise
 
Introduction to WebServices
Introduction to WebServicesIntroduction to WebServices
Introduction to WebServices
Khasim Cise
 
SunMicroSystems
SunMicroSystemsSunMicroSystems
SunMicroSystems
Khasim Cise
 
1. web services
1. web services1. web services
1. web services
Khasim Cise
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Khasim Cise
 
Scatter gather in mule
Scatter gather in muleScatter gather in mule
Scatter gather in mule
Khasim Cise
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
Khasim Cise
 
ESB introduction using Mule
ESB introduction using MuleESB introduction using Mule
ESB introduction using Mule
Khasim Cise
 
Mule Fundamentals
Mule FundamentalsMule Fundamentals
Mule Fundamentals
Khasim Cise
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Khasim Cise
 
Introduction to WebServices
Introduction to WebServicesIntroduction to WebServices
Introduction to WebServices
Khasim Cise
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Khasim Cise
 
Ad

Recently uploaded (20)

DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 

Mule using Salesforce

  • 1. Mule ESB 3.6 CRUD operations on Salesforce using Mule ESB
  • 2. Objective – Advantages of using Salesforce connector – How to perform Create, 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 Security Token. Then, click Reset My Security Token. 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 configuration XML 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 public Object 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 protected], 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 protected], 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' ] ]