Apex Integration Services 1744739133
Apex Integration Services 1744739133
Services in Salesforce
Callout or Web Service?
_ Key Concept
Client (Consumer)
1
the one making the request.
Server (Provider)
2
the one responding.
What is a Callout in Salesforce?
Definition:
A callout is when Salesforce acts as the client and makes a request
to an external system's API (REST or SOAP) to send or retrieve
data.
o Example:
Salesforce needs to check the current exchange rate by calling an
external banking API:
o Example:
An invoicing system needs to fetch customer records stored in Salesforce.
< REST:
@RestResource(urlMapping='/customer/*')
global with sharing class CustomerService {
@HttpGet
global static Contact getCustomer() {
return [SELECT Id, Name, Email FROM Contact LIMIT 1];
}
}
< SOAP:
Summary
Mock responses let you test your logic without calling real
services.
Test.setMock(WebServiceMock.class, new
MySoapMock());
@RestResource(urlMapping='/accountinfo/*')
global with sharing class AccountREST {
@HttpGet
global static Account getAccount() {
return [SELECT Name FROM Account LIMIT 1];
}
}
Accessible via:
https://yourInstance.salesforce.com/services/apexrest/a
ccountinfo/
Exposing a SOAP Web Service
More Info: