Month: February 2015

Salesforce Integration with SOAP API – Part 3 – Configure Eclipse for Enterprise WSDL

Preface – This post is part of “Salesforce Integration with SOAP API” series.In my previous posts, I have explained basics of SOAP API and WSDL. If you are not familiar with these concepts, I would request you to please check the posts @Salesforce Integration with SOAP API – Part 1 – Introduction to SOAP ProtocolSalesforce Integration with SOAP API – Part 2 – Introduction to WSDL and Salesforce’s ApproachNow here I will show step by step approach to configure eclipse IDE with Enterprise WSDL.Step 1 -Download WSDL from Salesforce Org by going to the below links -Setup | Build | Develop | API and then click on Generate Enterprise WSDL, followed by click on Generate button. It will open an XML file. You need to save the XML in your hard drive as enterprise.wsdlStep 2 -Here you need to download the Web Service Connector (WSC) from WSC project’s download page.So download wsc-23.jar from the above location and save it to the same folder where you have saved enterprise.wsdl in the previous step.Step 3 -In this step you need to create the executable jar. The command is as below -java -classpath wsc-23.jar enterprise.wsdl enterprise.jarThis will create an executable jar named enterprise.jar  in the same folder. Screenshot attached.Step 4 -Now you can create java project in Eclipse IDE and add the below jars to the build path -wsc-23.jarenterprise.jarThat’s all you need to do to configure...

Read More

Salesforce Integration – Creating XML Request using DOM + Custom Settings

Recently I got a requirement from one of my customer where I need to create the XML request and pass the same to a third party application using SOAP protocol. Initially I though it is very easy to do with Apex DOM APIs, but then I came to know that the other party (developer from that Third Party application) change their application quite frequently and as a result they need XML response in a different structure everytime they made some changes. Definitely my customer was very much irritated with this as they need to do code changes every time the other party do the change. So the important part of the requirement was to design something or do something so that with minimum (preferably no code change) changes Salesforce admin can handle the request from other party.Definitely quite a good challenge. Then after some discussion with the other party and Salesforce admin, I designed the application. The most complex part was how to create the XML Request dynamically(without any code change from Salesforce side) with new XML structure requirement.In this post, I will explain how I implemented the logic of creating XML Request with the help of Custom Settings. Yes, you are correct. Custom Settings is so powerful and important that you can play with it in many different ways and this post is one of the way.Let’s get...

Read More

Salesforce Integration with SOAP API – Part 2 – Introduction to WSDL and Salesforce’s Approach

Preface – This post is part of “Salesforce Integration with SOAP API” series.Introduction to WSDL –WSDL (Web Service Descriptive Language) is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information.Salesforce provides WSDL documents that describe –The public interface to the Web service.The protocol to be used for exchanging information (SOAP).In Salesforce we have two different types of WSDL documents –Enterprise WSDL – Strongly typed representation of an organization’s data.Partner WSDL – Loosely typed representation of an organization’s data.We should understand the differences between above two WSDLs. The differences are listed below –Enterprise WSDL –This is strongly typed.This is tied (bound) to a specific configuration of Salesforce.For any changes (Addition or Deletion of Custom Objects/Custom Fields) WSDL should be copied from the organization again.The enterprise WSDL is intended primarily for Customers.Partner WSDL –This is loosely typed.This can be used to reflect against any configuration of Salesforce.Partner WSDL is static. So if any changes are made to an organization’s Salesforce, partner WSDL should not be changed.The Partner WSDL is intended primarily for Partners.In my next post, I will explain how to configure eclipse IDE to connect to Salesforce using Java programming language. If you have any feedback, please let me know....

Read More

Salesforce Integration with SOAP API – Part 1 – Introduction to SOAP Protocol

Preface – This post is part of “Salesforce Integration with SOAP API” series.Introduction to SOAP – SOAP (Simple Object Access Protocol) is a network application messaging protocol used to exchange structured information between systems. It uses XML as message format and relies on application layer protocol, mainly HTTP, SMTP. It allows programs to run on separate machines and communicate using HTTP and it’s XML. To know more about SOAP, please visit below links:·· to SOAP API – SOAP API is a mechanism that allows external system to connect to Salesforce so that they can do CRUD operation, perform search operation, as well as perform administrative tasks.This SOAP API will expose the below details to external system –Standard Salesforce objects including all custom fields.All Custom Salesforce objects and all fields.Object Metadata.Using SOAP API, user can do below things –Perform CRUD (Create, Read, Update, Delete) operations on data.Query Salesforce data.Work with approval process.Create and update sharing records. As a best practice, developer should use the API options for creating Share records only during migration. Otherwise developer should always keep business rules out of Integration...

Read More

Spring ’15 – New Feature Added – Access Address and Geolocation Compound Fields Using Apex

Another feature added in Sprint ’15 is the ability to access Address and Geolocation Compound Field using Apex. I will explain the new feature with example below -First I will create a new field of type Geolocation in the User object as shown below -Now I will write the below code to access Location and Address details from User as below -public class UserLocation { public List<Double> getUserGeoLocation(String userName){ User anUser = [Select Id, Location__c from User where Username = :userName LIMIT 1]; Location location = anUser.Location__c; List<Double> geoLocation = new List<Double>(); geoLocation.add(location.latitude); geoLocation.add(location.longitude); return geoLocation; } public Address getUserAddress(String userName){ User anUser = [Select Id, Address from User where Username = :userName LIMIT 1]; return anUser.Address; }}I will write the test class also to test the functionality as shown below -@isTestpublic class UserLocationTest { @testSetup static void setup() { User userToCreate = new User(); //Add required information userToCreate.FirstName = ‘Sudipta’; userToCreate.LastName = ‘Deb’; userToCreate.Alias = ‘sdeb’; userToCreate.Email = ‘’; userToCreate.Username = ‘’; userToCreate.CommunityNickname = ‘Sudipta.Deb’; userToCreate.ProfileId = ’00eB0000000F8dB’; userToCreate.TimeZoneSidKey = ‘America/Denver’; userToCreate.LocaleSidKey = ‘en_US’; userToCreate.EmailEncodingKey = ‘UTF-8’; userToCreate.LanguageLocaleKey = ‘en_US’; //Adding the information Geolocation userToCreate.Location__Latitude__s = 22.5667; userToCreate.Location__Longitude__s = 88.3667; //Adding the Address information userToCreate.State = ‘West Bengal’; userToCreate.City = ‘Kolkata’; userToCreate.PostalCode = ‘12345’; userToCreate.Country = ‘India’; insert userToCreate; } static testMethod void testGetUserGeoLocation(){ UserLocation userLocation = new UserLocation(); Test.startTest(); List<Double> userGeoLocation = userLocation.getUserGeoLocation(‘’); Test.stopTest(); System.assertEquals(22.5667, userGeoLocation.get(0)); System.assertEquals(88.3667,...

Read More

Spring ’15 – New Feature Added – @testSetup

One of the very interesting feature added in Spring ’15 is @testSetup. In this post I will try to explain with example more about the feature. Below is what you will get from release note about @testSetup.Now let’s check with example -Below is the class/methods for which we need to write test methods – public class AccountHelper { public List<Account> getAllAccounts(){ List<Account> allAccounts = [Select Id from Account]; return allAccounts; } public Integer getEmployeeCountFrom(String accountNumber){ Account fetchedAccount = [Select Id, NumberOfEmployees from Account where AccountNumber = :accountNumber LIMIT 1]; return fetchedAccount.NumberOfEmployees; } public List<Case> getAllCases(Id accountId){ return [select ID from Case where AccountId = :accountId]; } public void updateEmployeeCountFor(String accountNumber, Integer newEmployeeCount){ Account fetchedAccount = [Select Id, NumberOfEmployees from Account where AccountNumber = :accountNumber LIMIT 1]; fetchedAccount.NumberOfEmployees = newEmployeeCount; update fetchedAccount; }}Previously we used to write test classes like below -@isTestpublic class AccountHelperTest { static testMethod void testGetAllAccounts(){ List<Account> accounts = new List<Account>(); for(Integer i=0;i < 100;i++){ accounts.add(new Account(Name = ‘Universal Container’)); } insert accounts; Test.startTest(); AccountHelper accountHelper = new AccountHelper(); List<Account> allAccounts = accountHelper.getAllAccounts(); Test.stopTest(); System.assertEquals(100, allAccounts.size()); } static testMethod void testGetEmployeeCountFrom(){ Account anAccount = new Account(); anAccount.Name = ‘Universal Container’; anAccount.AccountNumber = ‘TEST’; anAccount.NumberOfEmployees = 100; insert anAccount; Test.startTest(); AccountHelper accountHelper = new AccountHelper(); Integer numberOfEmployees = accountHelper.getEmployeeCountFrom(‘TEST’); Test.stopTest(); System.assertEquals(100, numberOfEmployees); } static testMethod void testGetAllCases(){ //Create the account first Account anAccount = new Account(); anAccount.Name = ‘Universal Container’; insert anAccount;...

Read More

Earlier Posts

  • 2024 (28)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)