SlideShare a Scribd company logo
2
Most read
3
Most read
12
Most read
Integrations
Inbound(REST and SOAP)
Outbound
Salesforce to Salesforce
 Create remote site settings first to allow the url to be accessible in salesforce.
Outbound Integration: How to invoke callouts
 1. From Setup, enter Remote Site Settings in the Quick Find box,
 2. Click Remote Site Settings.
 3. Click New Remote Site.
 4. Provide a name for the remote site
 5. Provide the URL for the remote site. This URL authorizes all subfolders for the endpoint, like
https://and https://th-apex-http-callout.herokuapp.com/path2. th-apex-http-
callout.herokuapp.com/path1
 6. Provide a description for the remote site / service.
 7. Click Save
To authorize remote callouts

public static HttpResponse makeGetCallout() {
 Http http = new Http();
 HttpRequest request = new HttpRequest();
 request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
 request.setMethod('GET');
 HttpResponse response = http.send(request);
 // If the request is successful, parse the JSON response.
 if (response.getStatusCode() == 200) {
 // Deserializes the JSON string into collections of primitive data types.
 Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
 // Cast the values in the 'animals' key as a list
 List<Object> animals = (List<Object>) results.get('animals');
 System.debug('Received the following animals:');
 for (Object animal: animals) {
 System.debug(animal);
 }
 }
 return response;
 }
Get the data using callouts using heroku endpoint
public static HttpResponse makePostCallout() {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
request.setBody('{"name":"mighty moose"}');
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
return response;
}
Post the data using callouts
Inbound Integration:How to expose Apex classes
 SOAP :Protocol Neutral – accessible via HTTP, SMTP, TCP and other
application level protocols. Only XML. Requires WSDL
 REST: REStricted to http protocol,but can use JSON, XML, Atom and
others.
Soap Cases
Soap Cases
Rest Api sample code
Workbench rest api demo
//use this url to call from workbench /services/apexrest/devlight1973/GetCase/5009000001NxD87
Connected app usage
 package sfdc_rest;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
 import org.apache.http.client.methods.*;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.ParseException;
 import org.apache.http.util.EntityUtils;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.client.ClientProtocolException;
 import org.json.JSONObject;
 import org.json.JSONTokener;
 import org.json.JSONException;
 public class Main {
 static final String USERNAME = "narenrr@yahoo.com";
 static final String PASSWORD = "2WHVAUUcVWbxXMmKFQDEl1sgK0";
 static final String LOGINURL = "https://login.salesforce.com";
 static final String GRANTSERVICE =
 "/services/oauth2/token?grant_type=password";
Advanced example – JAVA rest api
 Generate enterprise WSDL
 Generate Class wsdl
 Enter user name /pwd/token
 Get session id and url prefix
 Invoke method with session id and correct endpoint url
How to expose webservice with SOAP
Main differences between WSDL
 Between two prod orgs
 One will be sender,other will be reciever of changes
 Cannot be done with developer org.
Salesforce to Salesforce
 Bad news salesforce does not allow callouts to be tested.
 Good News: Mock callouts to the rescue. Basically simulates a static
resource as target ,instead of the actual url.
 Purpose is to get code coverage of callouts
Testing callouts
Implement the callout
Actual class doing callout
Test class for the same
@isTest
private class CalloutClassTest {
@isTest static void testCallout() {
// Set mock callout class
Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
HttpResponse res = CalloutClass.getInfoFromExternalService();
// Verify response received contains fake values
String contentType = res.getHeader('Content-Type');
System.assert(contentType == 'application/json');
String actualValue = res.getBody();
String expectedValue = '{"example":"test"}';
System.assertEquals(actualValue, expectedValue);
System.assertEquals(200, res.getStatusCode());
}
}

More Related Content

PPTX
Exploring the Salesforce REST API
PPT
JUnit 4
PPTX
Introduction à spring boot
PPT
Salesforce REST API
PDF
Oracle APEX Cheat Sheet
PDF
Lwc presentation
PPTX
Handling I/O in Java
PPTX
Spring boot
Exploring the Salesforce REST API
JUnit 4
Introduction à spring boot
Salesforce REST API
Oracle APEX Cheat Sheet
Lwc presentation
Handling I/O in Java
Spring boot

What's hot (20)

PPT
PDF
Javapolymorphism
PPTX
Laravel introduction
PDF
Design Patterns for Asynchronous Apex
PPT
Introduction to Javascript
PPT
Advanced Jasper Reports
PPTX
Salesforce Integration Pattern Overview
PPTX
Salesforce asynchronous apex
PPT
Graphql presentation
PPT
Jsp ppt
PPT
Java Threads and Concurrency
PPTX
1. Arrow Functions | JavaScript | ES6
PPT
Spring Boot in Action
PDF
Angular directives and pipes
PDF
Apex Enterprise Patterns: Building Strong Foundations
PDF
Java persistence api 2.1
PDF
flutter.school #HelloWorld
PPT
Postman.ppt
PPTX
Salesforce Integration Patterns
PPTX
Angular interview questions
Javapolymorphism
Laravel introduction
Design Patterns for Asynchronous Apex
Introduction to Javascript
Advanced Jasper Reports
Salesforce Integration Pattern Overview
Salesforce asynchronous apex
Graphql presentation
Jsp ppt
Java Threads and Concurrency
1. Arrow Functions | JavaScript | ES6
Spring Boot in Action
Angular directives and pipes
Apex Enterprise Patterns: Building Strong Foundations
Java persistence api 2.1
flutter.school #HelloWorld
Postman.ppt
Salesforce Integration Patterns
Angular interview questions
Ad

Similar to Salesforce Integration using REST SOAP and HTTP callouts (20)

DOCX
Salesforce Integration
PDF
SalesForce WebServices part 2
PDF
Webservices in SalesForce (part 1)
PPTX
Integration study group 2: Patterns
PDF
Integration step up session
PPTX
#ImpactSalesforceSaturday:360 degree view of salesforce integrations
PPTX
Integration on Force.com Platform
PPTX
SFDC Outbound Integrations
PPTX
Apex REST
PDF
Building towards a Composite API Framework in Salesforce
PPTX
Episode 9 - Building soap integrations in salesforce
PDF
REST - What's It All About? (SAP TechEd 2012, CD110)
PDF
Publishing Data to REST APIs with Lightning Process Builder
PDF
Hia 1691-using iib-to_support_api_economy
PPTX
February 2020 Salesforce API Review
PDF
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
PDF
Getting Started With Apex REST Services
PPTX
SFDC REST API
PDF
Api apex rest
PPTX
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
Salesforce Integration
SalesForce WebServices part 2
Webservices in SalesForce (part 1)
Integration study group 2: Patterns
Integration step up session
#ImpactSalesforceSaturday:360 degree view of salesforce integrations
Integration on Force.com Platform
SFDC Outbound Integrations
Apex REST
Building towards a Composite API Framework in Salesforce
Episode 9 - Building soap integrations in salesforce
REST - What's It All About? (SAP TechEd 2012, CD110)
Publishing Data to REST APIs with Lightning Process Builder
Hia 1691-using iib-to_support_api_economy
February 2020 Salesforce API Review
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Getting Started With Apex REST Services
SFDC REST API
Api apex rest
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Digital Strategies for Manufacturing Companies
PDF
AI in Product Development-omnex systems
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
medical staffing services at VALiNTRY
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
top salesforce developer skills in 2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Introduction to Artificial Intelligence
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
history of c programming in notes for students .pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Digital Strategies for Manufacturing Companies
AI in Product Development-omnex systems
Odoo Companies in India – Driving Business Transformation.pdf
medical staffing services at VALiNTRY
PTS Company Brochure 2025 (1).pdf.......
L1 - Introduction to python Backend.pptx
Reimagine Home Health with the Power of Agentic AI​
top salesforce developer skills in 2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Essential Infomation Tech presentation.pptx
Introduction to Artificial Intelligence
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Design an Analysis of Algorithms I-SECS-1021-03
How to Migrate SBCGlobal Email to Yahoo Easily
2025 Textile ERP Trends: SAP, Odoo & Oracle
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
history of c programming in notes for students .pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...

Salesforce Integration using REST SOAP and HTTP callouts

  • 2.  Create remote site settings first to allow the url to be accessible in salesforce. Outbound Integration: How to invoke callouts
  • 3.  1. From Setup, enter Remote Site Settings in the Quick Find box,  2. Click Remote Site Settings.  3. Click New Remote Site.  4. Provide a name for the remote site  5. Provide the URL for the remote site. This URL authorizes all subfolders for the endpoint, like https://and https://th-apex-http-callout.herokuapp.com/path2. th-apex-http- callout.herokuapp.com/path1  6. Provide a description for the remote site / service.  7. Click Save To authorize remote callouts
  • 4.  public static HttpResponse makeGetCallout() {  Http http = new Http();  HttpRequest request = new HttpRequest();  request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');  request.setMethod('GET');  HttpResponse response = http.send(request);  // If the request is successful, parse the JSON response.  if (response.getStatusCode() == 200) {  // Deserializes the JSON string into collections of primitive data types.  Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());  // Cast the values in the 'animals' key as a list  List<Object> animals = (List<Object>) results.get('animals');  System.debug('Received the following animals:');  for (Object animal: animals) {  System.debug(animal);  }  }  return response;  } Get the data using callouts using heroku endpoint
  • 5. public static HttpResponse makePostCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals'); request.setMethod('POST'); request.setHeader('Content-Type', 'application/json;charset=UTF-8'); request.setBody('{"name":"mighty moose"}'); HttpResponse response = http.send(request); // Parse the JSON response if (response.getStatusCode() != 201) { System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus()); } else { System.debug(response.getBody()); } return response; } Post the data using callouts
  • 6. Inbound Integration:How to expose Apex classes  SOAP :Protocol Neutral – accessible via HTTP, SMTP, TCP and other application level protocols. Only XML. Requires WSDL  REST: REStricted to http protocol,but can use JSON, XML, Atom and others.
  • 10. Workbench rest api demo //use this url to call from workbench /services/apexrest/devlight1973/GetCase/5009000001NxD87
  • 12.  package sfdc_rest;  import java.io.IOException;  import java.io.InputStream;  import java.net.URISyntaxException;  import org.apache.http.client.methods.*;  import org.apache.http.impl.client.DefaultHttpClient;  import org.apache.http.HttpResponse;  import org.apache.http.HttpStatus;  import org.apache.http.ParseException;  import org.apache.http.util.EntityUtils;  import org.apache.http.client.utils.URIBuilder;  import org.apache.http.client.ClientProtocolException;  import org.json.JSONObject;  import org.json.JSONTokener;  import org.json.JSONException;  public class Main {  static final String USERNAME = "narenrr@yahoo.com";  static final String PASSWORD = "2WHVAUUcVWbxXMmKFQDEl1sgK0";  static final String LOGINURL = "https://login.salesforce.com";  static final String GRANTSERVICE =  "/services/oauth2/token?grant_type=password"; Advanced example – JAVA rest api
  • 13.  Generate enterprise WSDL  Generate Class wsdl  Enter user name /pwd/token  Get session id and url prefix  Invoke method with session id and correct endpoint url How to expose webservice with SOAP
  • 15.  Between two prod orgs  One will be sender,other will be reciever of changes  Cannot be done with developer org. Salesforce to Salesforce
  • 16.  Bad news salesforce does not allow callouts to be tested.  Good News: Mock callouts to the rescue. Basically simulates a static resource as target ,instead of the actual url.  Purpose is to get code coverage of callouts Testing callouts
  • 19. Test class for the same @isTest private class CalloutClassTest { @isTest static void testCallout() { // Set mock callout class Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator()); HttpResponse res = CalloutClass.getInfoFromExternalService(); // Verify response received contains fake values String contentType = res.getHeader('Content-Type'); System.assert(contentType == 'application/json'); String actualValue = res.getBody(); String expectedValue = '{"example":"test"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode()); } }