<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Salesforce Integration - Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</title>
	<atom:link href="https://vinodsebastian.com/category/it-made-easy-cat/salesforce-cat/salesforce-integration-cat/feed/" rel="self" type="application/rss+xml" />
	<link>https://vinodsebastian.com</link>
	<description>Hi I&#039;m a Web Architect by Profession and an Artist by nature. I love empowering People, aligning to Processes and delivering Projects.</description>
	<lastBuildDate>Sat, 06 Dec 2025 01:25:55 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://vinodsebastian.com/wp-content/uploads/2020/12/cropped-Me-32x32.jpg</url>
	<title>Salesforce Integration - Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</title>
	<link>https://vinodsebastian.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Salesforce: Connected Apps, Auth Provider and Named Credentials</title>
		<link>https://vinodsebastian.com/salesforce-connected-apps-auth-provider-and-named-credentials/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesforce-connected-apps-auth-provider-and-named-credentials</link>
		
		<dc:creator><![CDATA[vinodsebastian]]></dc:creator>
		<pubDate>Tue, 02 Dec 2025 06:55:36 +0000</pubDate>
				<category><![CDATA[Salesforce Integration]]></category>
		<category><![CDATA[IT Made Easy]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">https://vinodsebastian.com/?page_id=2588</guid>

					<description><![CDATA[<p>Salesforce: Connected Apps, Auth Provider and Named Credentials Connected Apps A Connected App in Salesforce is a framework that enables external applications such as mobile apps, web apps, and APIs to securely connect with Salesforce. It supports various protocols including OAuth 2.0, SAML, and OpenID Connect. Key Features: Define OAuth scopes to specify what data [&#8230;]</p>
<p>The post <a href="https://vinodsebastian.com/salesforce-connected-apps-auth-provider-and-named-credentials/">Salesforce: Connected Apps, Auth Provider and Named Credentials</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></description>
										<content:encoded><![CDATA[<article>
<h1>Salesforce: Connected Apps, Auth Provider and Named Credentials</h1>
<h2>Connected Apps</h2>
<p>A Connected App in Salesforce is a framework that enables external applications such as mobile apps, web apps, and APIs to securely connect with Salesforce. It supports various protocols including OAuth 2.0, SAML, and OpenID Connect.</p>
<ul>
<li><strong>Key Features:</strong>
<ul>
<li>Define OAuth scopes to specify what data the app can access.</li>
<li>Configure callback URLs for OAuth flows.</li>
<li>Control IP restrictions, session policies, and permitted users.</li>
</ul>
</li>
<li><strong>Use Cases:</strong>
<ul>
<li>Allowing a mobile app to access Salesforce data.</li>
<li>Enabling third-party integrations with platforms like Slack and Google Workspace.</li>
<li>Providing Single Sign-On (SSO) for external applications.</li>
</ul>
</li>
</ul>
<h2><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f511.png" alt="🔑" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Auth Provider</h2>
<p>An Auth Provider in Salesforce allows the platform to utilize an external identity provider (IdP) for authentication purposes. It supports protocols such as OAuth 2.0, OpenID Connect, and SAML.</p>
<ul>
<li><strong>Key Features:</strong>
<ul>
<li>Define the provider type (e.g., Salesforce, Google, Facebook, Azure AD).</li>
<li>Store client ID, client secret, authorization/token URLs.</li>
<li>Utilize registration handlers (Apex classes) for managing user provisioning.</li>
</ul>
</li>
<li><strong>Use Cases:</strong>
<ul>
<li>Allowing Salesforce users to log in using Google, Facebook, or another Salesforce org.</li>
<li>Enabling Named Credentials for secure server-to-server callouts from Salesforce to external APIs.</li>
<li>Supporting SSO where Salesforce trusts an external IdP for authentication.</li>
</ul>
</li>
</ul>
<h2>Named Credentials</h2>
<p>Named Credentials provide a secure method to store authentication details for external callouts, such as REST or SOAP APIs, in Salesforce.</p>
<ul>
<li><strong>Key Features:</strong>
<ul>
<li>Store the endpoint URL, authentication protocol (OAuth, Basic, JWT).</li>
<li>Automatically handle token refresh and credential rotation.</li>
<li>Simplify Apex callouts by referencing the Named Credential instead of hardcoding URLs or secrets.</li>
</ul>
</li>
<li><strong>Use Cases:</strong>
<ul>
<li>Salesforce making callouts to external APIs like Google Maps, SAP, or AWS.</li>
<li>Securely managing credentials without exposing them in Apex code.</li>
<li>Combining with Auth Providers for OAuth flows.</li>
</ul>
</li>
</ul>
<h2>How They Work Together</h2>
<ul>
<li><strong>Connected App:</strong> Represents an external app connecting into Salesforce.</li>
<li><strong>Auth Provider:</strong> Represents an external IdP that Salesforce trusts for authentication.</li>
<li><strong>Named Credential:</strong> Represents Salesforce making secure callouts to an external service.</li>
</ul>
<p>Example Flow:</p>
<ol>
<li>You build a Salesforce integration with Google APIs.</li>
<li>You configure an Auth Provider for Google (OAuth 2.0).</li>
<li>You create a Named Credential that uses the Auth Provider.</li>
<li>Your Apex code calls the Named Credential endpoint, and Salesforce automatically handles authentication.</li>
<li>If you want Google to call Salesforce, you configure a Connected App in Salesforce for Google.</li>
</ol>
<h2>Key Takeaways</h2>
<ul>
<li><strong>Connected Apps:</strong> External apps integrating into Salesforce.</li>
<li><strong>Auth Providers:</strong> Salesforce integrating out to external IdPs.</li>
<li><strong>Named Credentials:</strong> Salesforce securely storing credentials for outbound callouts.</li>
<li>Together, they form the authentication and integration backbone of Salesforce.</li>
</ul>
</article><p>The post <a href="https://vinodsebastian.com/salesforce-connected-apps-auth-provider-and-named-credentials/">Salesforce: Connected Apps, Auth Provider and Named Credentials</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Salesforce: Creating SOAP Web Service</title>
		<link>https://vinodsebastian.com/salesforce-creating-soap-web-service/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesforce-creating-soap-web-service</link>
		
		<dc:creator><![CDATA[vinodsebastian]]></dc:creator>
		<pubDate>Tue, 02 Dec 2025 06:43:59 +0000</pubDate>
				<category><![CDATA[Salesforce Integration]]></category>
		<category><![CDATA[IT Made Easy]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">https://vinodsebastian.com/?page_id=2567</guid>

					<description><![CDATA[<p>Salesforce: Creating SOAP Web Service Overview In Salesforce, you can create SOAP (Simple Object Access Protocol) web services using Apex classes. SOAP web services allow external applications to interact with Salesforce by calling exposed methods via SOAP requests. This guide will walk you through the steps to create a SOAP web service in Salesforce. Steps [&#8230;]</p>
<p>The post <a href="https://vinodsebastian.com/salesforce-creating-soap-web-service/">Salesforce: Creating SOAP Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></description>
										<content:encoded><![CDATA[<article>
<h1>Salesforce: Creating SOAP Web Service</h1>
<h2>Overview</h2>
<p>In Salesforce, you can create SOAP (Simple Object Access Protocol) web services using Apex classes. SOAP web services allow external applications to interact with Salesforce by calling exposed methods via SOAP requests. This guide will walk you through the steps to create a SOAP web service in Salesforce.</p>
<h2>Steps to Create a SOAP Web Service in Salesforce</h2>
<h3>1. Define a Global Apex Class</h3>
<p>To create a SOAP web service in Salesforce, you need to define a global Apex class with methods that you want to expose to external systems.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">global class AccountService {
    // Expose a method to create an Account
    webService static Id createAccount(String name, String phone) {
        Account acc = new Account(Name = name, Phone = phone);
        insert acc;
        return acc.Id;
    }

    // Expose a method to fetch Account details
    webService static Account getAccount(Id accountId) {
        return [SELECT Id, Name, Phone FROM Account WHERE Id = :accountId LIMIT 1];
    }
}</pre>
<p>Explanation:</p>
<ul>
<li>Use the global access modifier to make the class accessible outside Salesforce.</li>
<li>Use the <code>webService</code> keyword to expose methods as web services.</li>
</ul>
<h3>2. Generate the WSDL</h3>
<p>WSDL (Web Services Description Language) is a standard XML format for describing web services and how to access them. In Salesforce, you can generate the WSDL for your web service.</p>
<p>Steps to generate the WSDL:</p>
<ol>
<li>Go to Setup.</li>
<li>Navigate to Apex Classes.</li>
<li>Click on your class.</li>
<li>Click on &#8220;Generate WSDL&#8221;.</li>
</ol>
<p>Download the generated WSDL file. External systems use this file to understand and interact with your SOAP web service.</p>
<h3>3. Consume the Service</h3>
<p>External applications that want to interact with your SOAP web service need to import the WSDL into their development environment, such as Java or .NET. They can then make SOAP requests to call the exposed methods like <code>createAccount</code> and <code>getAccount</code>.</p>
<h3>4. Example SOAP Request</h3>
<p>An example SOAP request to create an Account might look like:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:acc=&quot;http://soap.sforce.com/schemas/class/AccountService&quot;&gt;
   &lt;soapenv:Header/&gt;
   &lt;soapenv:Body&gt;
      &lt;acc:createAccount&gt;
         &lt;name&gt;Test Account&lt;/name&gt;
         &lt;phone&gt;1234567890&lt;/phone&gt;
      &lt;/acc:createAccount&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre>
<h3>5. Authentication</h3>
<p>External clients interacting with your Salesforce SOAP web service must authenticate themselves. This can be done through the <code>login()</code> SOAP call or OAuth. After successful authentication, the session ID is passed in the SOAP header (<code>SessionHeader</code>) for subsequent calls to maintain a secure connection.</p>
<h2>Key Concepts</h2>
<p>Here are some key concepts to remember when creating SOAP web services in Salesforce:</p>
<ul>
<li><strong>global keyword:</strong> It makes the class and methods visible outside Salesforce.</li>
<li><strong>webService keyword:</strong> Marks methods as callable via SOAP.</li>
<li><strong>WSDL file:</strong> Acts as a contract between Salesforce and external systems.</li>
<li><strong>Session ID:</strong> Ensures secure communication between Salesforce and external systems.</li>
<li><strong>Error Handling:</strong> Exceptions thrown in Apex are reflected in the SOAP fault response.</li>
</ul>
<h2>Conclusion</h2>
<p>Creating SOAP web services in Salesforce using Apex classes allows you to integrate external systems with your Salesforce instance. By following the steps outlined in this guide, you can expose custom functionality or CRUD operations as SOAP methods, enabling seamless interaction between Salesforce and external applications.</p>
<p>Sources: Salesforce Developer Guide sample code</p>
</article><p>The post <a href="https://vinodsebastian.com/salesforce-creating-soap-web-service/">Salesforce: Creating SOAP Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Salesforce: Consuming SOAP Web Service</title>
		<link>https://vinodsebastian.com/salesforce-consuming-soap-web-service/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesforce-consuming-soap-web-service</link>
		
		<dc:creator><![CDATA[vinodsebastian]]></dc:creator>
		<pubDate>Tue, 02 Dec 2025 06:43:40 +0000</pubDate>
				<category><![CDATA[Salesforce Integration]]></category>
		<category><![CDATA[IT Made Easy]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">https://vinodsebastian.com/?page_id=2566</guid>

					<description><![CDATA[<p>Salesforce: Consuming SOAP Web Service Importing the WSDL Salesforce acts as the client calling an external SOAP web service. This process is achieved through Apex callouts using the WSDL (Web Services Description Language) provided by the external system. Obtain the WSDL file from the external SOAP service provider. In Salesforce Setup, navigate to Apex Classes [&#8230;]</p>
<p>The post <a href="https://vinodsebastian.com/salesforce-consuming-soap-web-service/">Salesforce: Consuming SOAP Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></description>
										<content:encoded><![CDATA[<article>
<h1>Salesforce: Consuming SOAP Web Service</h1>
<h2>Importing the WSDL</h2>
<p>Salesforce acts as the client calling an external SOAP web service. This process is achieved through Apex callouts using the WSDL (Web Services Description Language) provided by the external system.</p>
<ul>
<li>Obtain the WSDL file from the external SOAP service provider.</li>
<li>In Salesforce Setup, navigate to Apex Classes → Generate from WSDL.</li>
<li>Upload the WSDL file. Salesforce will then generate Apex classes (referred to as stubs) that represent the SOAP operations and data types defined in the WSDL.</li>
</ul>
<h2>Example Apex Code to Call External SOAP Service</h2>
<p>Once the WSDL is imported and the Apex classes are generated, you can write Apex code to interact with the external SOAP service.</p>
<p>For instance, if the external SOAP service offers an operation like getWeather(city), Salesforce will create a stub class based on the WSDL, such as WeatherService.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">public class WeatherConsumer {
    public static String getWeatherForCity(String cityName) {
        // Create an instance of the stub from the generated WSDL class
        WeatherServiceSoap ws = new WeatherServiceSoap();
        
        // Set the endpoint (can be from WSDL or overridden if necessary)
        ws.endpoint_x = &#039;https://api.example.com/soap/weather&#039;;
        
        // Call the SOAP operation
        String result = ws.getWeather(cityName);
        
        System.debug(&#039;Weather result: &#039; + result);
        return result;
    }
}</pre>
<h2>Authentication</h2>
<p>Many SOAP services require authentication using credentials such as username/password, API key, or token. Salesforce-generated stubs typically include a SoapHeader class where you can set these credentials.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">WeatherServiceSoap ws = new WeatherServiceSoap();
ws.inputHttpHeaders_x = new Map&lt;String, String&gt;();
ws.inputHttpHeaders_x.put(&#039;Authorization&#039;, &#039;Bearer YOUR_TOKEN&#039;);
// Or, if the WSDL defines a LoginHeader, you set it like:
WeatherService.LoginHeader header = new WeatherService.LoginHeader();
header.username = &#039;myUser&#039;;
header.password = &#039;myPass&#039;;
ws.SessionHeader = header;</pre>
<h2>Testing with Mock Data</h2>
<p>When testing Salesforce code that interacts with external SOAP services, it is essential to use mock data to simulate responses. This is due to the restriction on making actual callouts during tests.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">@isTest
private class WeatherConsumerTest {
    @isTest static void testGetWeatherForCity() {
        // Mock the SOAP response
        Test.startTest();
        // You can use HttpCalloutMock if the SOAP stub internally uses Http
        Test.setMock(HttpCalloutMock.class, new WeatherMock());
        
        String result = WeatherConsumer.getWeatherForCity(&#039;Cochin&#039;);
        
        Test.stopTest();
        System.assertEquals(&#039;Sunny&#039;, result);
    }
}

// Mock class
global class WeatherMock implements HttpCalloutMock {
    global HttpResponse respond(HttpRequest req) {
        HttpResponse res = new HttpResponse();
        res.setStatusCode(200);
        // Simplified SOAP response body
        res.setBody(&#039;Sunny&#039;);
        return res;
    }
}</pre>
<h2>Explanation</h2>
<ul>
<li><strong>WSDL Import:</strong> This step generates Apex classes (stubs) that represent the SOAP service based on the WSDL.</li>
<li><strong>Stub Usage:</strong> Instantiating the stub allows you to call its methods like regular Apex methods.</li>
<li><strong>Authentication:</strong> Authentication is often managed through SOAP or HTTP headers.</li>
<li><strong>Testing:</strong> Utilize HttpCalloutMock to mimic SOAP responses in test classes, as real callouts are restricted.</li>
</ul>
<h2>Key Takeaways</h2>
<ul>
<li>Salesforce can consume external SOAP services by importing WSDLs and utilizing generated Apex stubs.</li>
<li>Authentication mechanisms are typically required and can be managed via headers.</li>
<li>Always incorporate mock-based test classes for SOAP callouts to ensure proper functionality.</li>
<li>This approach is commonly used to integrate Salesforce with legacy systems that expose SOAP APIs.</li>
</ul>
</article><p>The post <a href="https://vinodsebastian.com/salesforce-consuming-soap-web-service/">Salesforce: Consuming SOAP Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Salesforce: Consuming REST Web Service</title>
		<link>https://vinodsebastian.com/salesforce-consuming-rest-web-service/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesforce-consuming-rest-web-service</link>
		
		<dc:creator><![CDATA[vinodsebastian]]></dc:creator>
		<pubDate>Tue, 02 Dec 2025 06:43:16 +0000</pubDate>
				<category><![CDATA[Salesforce Integration]]></category>
		<category><![CDATA[IT Made Easy]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">https://vinodsebastian.com/?page_id=2565</guid>

					<description><![CDATA[<p>Salesforce: Consuming REST Web Service Overview Salesforce can act as a client calling an external REST API by utilizing Apex callouts. This article provides a step-by-step guide on how to consume a REST service in Salesforce. Step 1: Enable Callouts To enable callouts in Salesforce, follow these steps: Add the external endpoint to Remote Site [&#8230;]</p>
<p>The post <a href="https://vinodsebastian.com/salesforce-consuming-rest-web-service/">Salesforce: Consuming REST Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></description>
										<content:encoded><![CDATA[<article>
<h1>Salesforce: Consuming REST Web Service</h1>
<h2>Overview</h2>
<p>Salesforce can act as a client calling an external REST API by utilizing Apex callouts. This article provides a step-by-step guide on how to consume a REST service in Salesforce.</p>
<h2>Step 1: Enable Callouts</h2>
<p>To enable callouts in Salesforce, follow these steps:</p>
<ul>
<li>Add the external endpoint to Remote Site Settings by navigating to Setup → Security → Remote Site Settings. This step is crucial as Salesforce blocks callouts by default.</li>
</ul>
<h2>Step 2: Apex Code to Consume REST Service</h2>
<p>Below is a simple example of Salesforce consuming a REST API through Apex:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
public class RestConsumerExample {
    public static void getWeatherData(String city) {
        // Prepare the HTTP request
        Http http = new Http();
        HttpRequest req = new HttpRequest();

        // Example external REST API endpoint
        String endpoint = &#039;https://api.example.com/weather/&#039; + city;
        req.setEndpoint(endpoint);
        req.setMethod(&#039;GET&#039;);

        // Add headers if needed (e.g., authentication)
        req.setHeader(&#039;Authorization&#039;, &#039;Bearer YOUR_ACCESS_TOKEN&#039;);
        req.setHeader(&#039;Content-Type&#039;, &#039;application/json&#039;);

        // Send the request
        HttpResponse res = http.send(req);

        // Handle the response
        if (res.getStatusCode() == 200) {
            System.debug(&#039;Response Body: &#039; + res.getBody());
        } else {
            System.debug(&#039;Error: &#039; + res.getStatusCode() + &#039; &#039; + res.getStatus());
        }
    }
}</pre>
<h2>Step 3: Parsing JSON Response</h2>
<p>To parse JSON responses in Salesforce, you can use JSON.deserialize to convert JSON into Apex objects. Here&#8217;s an example:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
public class WeatherResponse {
    public String city;
    public String temperature;
    public String condition;
}

public class RestConsumerExample {
    public static WeatherResponse getWeatherData(String city) {
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(&#039;https://api.example.com/weather/&#039; + city);
        req.setMethod(&#039;GET&#039;);
        req.setHeader(&#039;Authorization&#039;, &#039;Bearer YOUR_ACCESS_TOKEN&#039;);

        HttpResponse res = http.send(req);

        if (res.getStatusCode() == 200) {
            WeatherResponse wr = (WeatherResponse) JSON.deserialize(res.getBody(), WeatherResponse.class);
            return wr;
        } else {
            throw new CalloutException(&#039;Failed with status: &#039; + res.getStatusCode());
        }
    }
}</pre>
<h2>Step 4: Test Class Example</h2>
<p>It is essential to write test classes to validate the callout logic. Here&#8217;s a test class example:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
@isTest
private class RestConsumerExampleTest {
    @isTest static void testGetWeatherData() {
        // Mock the HTTP response
        Test.startTest();
        HttpResponse res = new HttpResponse();
        res.setStatusCode(200);
        res.setBody(&#039;{&quot;city&quot;:&quot;Cochin&quot;,&quot;temperature&quot;:&quot;30C&quot;,&quot;condition&quot;:&quot;Sunny&quot;}&#039;);

        // Use HttpCalloutMock to simulate the external service
        Test.setMock(HttpCalloutMock.class, new WeatherMock());

        WeatherResponse wr = RestConsumerExample.getWeatherData(&#039;Cochin&#039;);
        Test.stopTest();

        System.assertEquals(&#039;Cochin&#039;, wr.city);
        System.assertEquals(&#039;30C&#039;, wr.temperature);
        System.assertEquals(&#039;Sunny&#039;, wr.condition);
    }
}

// Mock class
global class WeatherMock implements HttpCalloutMock {
    global HTTPResponse respond(HTTPRequest req) {
        HttpResponse res = new HttpResponse();
        res.setStatusCode(200);
        res.setBody(&#039;{&quot;city&quot;:&quot;Cochin&quot;,&quot;temperature&quot;:&quot;30C&quot;,&quot;condition&quot;:&quot;Sunny&quot;}&#039;);
        return res;
    }
}</pre>
<h2>Explanation</h2>
<p>Here are some key points to remember while consuming REST services in Salesforce:</p>
<ul>
<li><strong>Http &amp; HttpRequest:</strong> Apex classes used for making REST callouts.</li>
<li><strong>Remote Site Settings:</strong> Required to whitelist external endpoints.</li>
<li><strong>Headers:</strong> Used for authentication such as Bearer tokens and API keys.</li>
<li><strong>JSON.deserialize:</strong> Converts JSON responses into Apex objects.</li>
<li><strong>Test.setMock:</strong> Necessary for unit testing callouts as Salesforce prohibits real HTTP calls in tests.</li>
</ul>
<h2>Key Takeaways</h2>
<ul>
<li>Salesforce can function as a REST client using Apex callouts.</li>
<li>Always configure Remote Site Settings for external endpoints to ensure smooth callouts.</li>
<li>Utilize JSON.deserialize to effectively parse responses into Apex objects.</li>
<li>Write mock-based test classes to validate the functionality of callouts.</li>
</ul>
</article><p>The post <a href="https://vinodsebastian.com/salesforce-consuming-rest-web-service/">Salesforce: Consuming REST Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Salesforce: Web Services</title>
		<link>https://vinodsebastian.com/salesforce-web-services/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesforce-web-services</link>
		
		<dc:creator><![CDATA[vinodsebastian]]></dc:creator>
		<pubDate>Tue, 02 Dec 2025 06:42:46 +0000</pubDate>
				<category><![CDATA[Salesforce Integration]]></category>
		<category><![CDATA[IT Made Easy]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">https://vinodsebastian.com/?page_id=2568</guid>

					<description><![CDATA[<p>Salesforce: Web Services SOAP Web Services SOAP (Simple Object Access Protocol) is a protocol-based web service that uses XML for messaging. Here are some key points about SOAP web services: Protocol-based: SOAP is a strict XML-based messaging protocol. Contract-driven: Requires a WSDL (Web Services Description Language) file that defines operations, types, and bindings. Features: Strong [&#8230;]</p>
<p>The post <a href="https://vinodsebastian.com/salesforce-web-services/">Salesforce: Web Services</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></description>
										<content:encoded><![CDATA[<article>
<h1>Salesforce: Web Services</h1>
<h2>SOAP Web Services</h2>
<p>SOAP (Simple Object Access Protocol) is a protocol-based web service that uses XML for messaging. Here are some key points about SOAP web services:</p>
<ul>
<li><strong>Protocol-based</strong>: SOAP is a strict XML-based messaging protocol.</li>
<li><strong>Contract-driven</strong>: Requires a WSDL (Web Services Description Language) file that defines operations, types, and bindings.</li>
<li><strong>Features</strong>:
<ul>
<li>Strong typing and formal contracts</li>
<li>Built-in error handling via SOAP faults</li>
<li>Extensible headers (security, transactions, etc.)</li>
</ul>
</li>
<li><strong>Use cases</strong>: SOAP Web Services are commonly used for enterprise integrations, legacy systems, banking applications, and scenarios that require strict standards and reliability.</li>
</ul>
<h2>REST Web Services</h2>
<p>REST (Representational State Transfer) is an architectural style that is not protocol-based. It focuses on exposing resources through URLs and typically uses JSON or XML payloads. Here are some key points about REST web services:</p>
<ul>
<li><strong>Architectural style</strong>: REST is not a protocol but a design style.</li>
<li><strong>Resource-driven</strong>: Exposes resources via URLs, typically using JSON or XML payloads.</li>
<li><strong>Features</strong>:
<ul>
<li>Lightweight and faster than SOAP</li>
<li>Uses standard HTTP verbs (GET, POST, PUT, DELETE)</li>
<li>Easier to consume with modern clients (JavaScript, mobile apps, etc.)</li>
</ul>
</li>
<li><strong>Use cases</strong>: REST Web Services are suitable for modern APIs, mobile/web applications, and integrations where simplicity and speed are important.</li>
</ul>
<h2>Salesforce Context</h2>
<p>Salesforce supports both SOAP and REST web services for integration and development. Here&#8217;s how Salesforce integrates with these web service types:</p>
<ul>
<li><strong>SOAP</strong>: Salesforce allows the creation of Apex classes with webService methods which can be consumed via WSDL.</li>
<li><strong>REST</strong>: Salesforce supports Apex classes annotated with @RestResource, which can be consumed via HTTP endpoints returning JSON.</li>
</ul>
<h2>APIs in Salesforce</h2>
<p>Salesforce provides various APIs to help developers interact with Salesforce programmatically. These APIs enable integration with external systems, automate business processes, and customize Salesforce functionalities.</p>
<h3>Callouts</h3>
<p>Salesforce callouts allow the execution of HTTP requests to external services from Apex code. These callouts are essential for integrating Salesforce with external APIs, sending data to third-party services, or fetching information from external sources.</p>
</article><p>The post <a href="https://vinodsebastian.com/salesforce-web-services/">Salesforce: Web Services</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Salesforce: Creating REST Web Service</title>
		<link>https://vinodsebastian.com/salesforce-creating-rest-web-service/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesforce-creating-rest-web-service</link>
		
		<dc:creator><![CDATA[vinodsebastian]]></dc:creator>
		<pubDate>Tue, 02 Dec 2025 06:42:14 +0000</pubDate>
				<category><![CDATA[Salesforce Integration]]></category>
		<category><![CDATA[IT Made Easy]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">https://vinodsebastian.com/?page_id=2564</guid>

					<description><![CDATA[<p>Salesforce: Creating REST Web Service Define the REST Resource Class To create a RESTful web service in Salesforce, you need to define a REST resource class. Here is an example: @RestResource(urlMapping=&#039;/AccountService/*&#039;) global with sharing class AccountRestService { // GET method: fetch account details @HttpGet global static Account doGet() { RestRequest req = RestContext.request; RestResponse res [&#8230;]</p>
<p>The post <a href="https://vinodsebastian.com/salesforce-creating-rest-web-service/">Salesforce: Creating REST Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></description>
										<content:encoded><![CDATA[<article>
<h1>Salesforce: Creating REST Web Service</h1>
<h2>Define the REST Resource Class</h2>
<p>To create a RESTful web service in Salesforce, you need to define a REST resource class. Here is an example:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">@RestResource(urlMapping=&#039;/AccountService/*&#039;)
global with sharing class AccountRestService {
    // GET method: fetch account details
    @HttpGet
    global static Account doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        
        // Extract accountId from the URL
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf(&#039;/&#039;)+1);
        Account acc = [SELECT Id, Name, Phone FROM Account WHERE Id = :accountId LIMIT 1];
        
        return acc;
    }
    
    // POST method: create a new account
    @HttpPost
    global static Id doPost(String name, String phone) {
        Account acc = new Account(Name = name, Phone = phone);
        insert acc;
        
        return acc.Id;
    }
    
    // DELETE method: delete an account
    @HttpDelete
    global static String doDelete() {
        RestRequest req = RestContext.request;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf(&#039;/&#039;)+1);
        delete [SELECT Id FROM Account WHERE Id = :accountId LIMIT 1];
        
        return &#039;Account deleted successfully&#039;;
    }
}</pre>
<p>The <code>@RestResource(urlMapping='/AccountService/*')</code> defines the endpoint where external clients can call URLs like <code>https://yourInstance.salesforce.com/services/apexrest/AccountService/{Id}</code>.</p>
<p>The <code>@HttpGet</code>, <code>@HttpPost</code>, and <code>@HttpDelete</code> annotations map Apex methods to HTTP verbs. The <code>RestRequest</code> and <code>RestResponse</code> classes provide access to request parameters, headers, and response handling.</p>
<p>Salesforce automatically serializes Apex objects, like the <code>Account</code> object, into JSON for responses.</p>
<h2>Example REST Calls</h2>
<p>Here are examples of REST calls you can make to interact with the Salesforce REST web service:</p>
<ul>
<li><strong>GET Request:</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="">GET https://yourInstance.salesforce.com/services/apexrest/AccountService/001XXXXXXXXXXXX
Authorization: Bearer</pre>
<p><strong>Response:</strong></p>
<pre class="EnlighterJSRAW" data-enlighter-language="">{
    &quot;Id&quot;: &quot;001XXXXXXXXXXXX&quot;,
    &quot;Name&quot;: &quot;Test Account&quot;,
    &quot;Phone&quot;: &quot;1234567890&quot;
}</pre>
<ul>
<li><strong>POST Request:</strong></li>
</ul>
<pre class="EnlighterJSRAW" data-enlighter-language="">POST https://yourInstance.salesforce.com/services/apexrest/AccountService/
Authorization: Bearer 
Content-Type: application/json
{
    &quot;name&quot;: &quot;New Account&quot;,
    &quot;phone&quot;: &quot;9876543210&quot;
}</pre>
<p><strong>Response:</strong></p>
<p>&#8220;001YYYYYYYYYYYY&#8221;</p>
<p>Below is an example test class for the <code>AccountRestService</code> class:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">@isTest
private class AccountRestServiceTest {
    @isTest static void testDoPostAndGet() {
        // Simulate POST
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        req.requestURI = &#039;/services/apexrest/AccountService/&#039;;
        req.httpMethod = &#039;POST&#039;;
        RestContext.request = req;
        RestContext.response = res;
        
        Id accId = AccountRestService.doPost(&#039;Unit Test Account&#039;, &#039;111222333&#039;);
        
        // Verify account created
        Account acc = [SELECT Name, Phone FROM Account WHERE Id = :accId];
        System.assertEquals(&#039;Unit Test Account&#039;, acc.Name);
        
        // Simulate GET
        req.requestURI = &#039;/services/apexrest/AccountService/&#039; + accId;
        req.httpMethod = &#039;GET&#039;;
        RestContext.request = req;
        Account fetched = AccountRestService.doGet();
        System.assertEquals(accId, fetched.Id);
    }
    
    @isTest static void testDoDelete() {
        Account acc = new Account(Name=&#039;Delete Me&#039;);
        insert acc;
        
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        req.requestURI = &#039;/services/apexrest/AccountService/&#039; + acc.Id;
        req.httpMethod = &#039;DELETE&#039;;
        RestContext.request = req;
        RestContext.response = res;
        
        String result = AccountRestService.doDelete();
        System.assertEquals(&#039;Account deleted successfully&#039;, result);
        System.assertEquals(0, [SELECT COUNT() FROM Account WHERE Id = :acc.Id]);
    }
}</pre>
<h2>Key Takeaways</h2>
<ul>
<li>REST services in Salesforce are built using Apex classes with <code>@RestResource</code> annotations.</li>
<li>Methods are exposed via HTTP verbs such as <code>@HttpGet</code> and <code>@HttpPost</code>.</li>
<li>Authentication is mandatory, with OAuth access token provided in the <code>Authorization: Bearer</code> header.</li>
<li>Salesforce automatically serializes Apex objects into JSON for responses.</li>
<li>Always write test classes to validate your REST logic and meet deployment requirements.</li>
</ul>
</article><p>The post <a href="https://vinodsebastian.com/salesforce-creating-rest-web-service/">Salesforce: Creating REST Web Service</a> first appeared on <a href="https://vinodsebastian.com">Vinod Sebastian - B.Tech, M.Com, PGCBM, PGCPM, PGDBIO</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
