Salesforce provides a very good feature to connect Salesforce with third party applications for extended use. Suppose a company requires a website on WordPress or a Mobile Application, then using Salesforce SOAP web services you can bind third party applications with Salesforce to perform CRUD ( Create, Read, Update & Delete) operations.
Salesforce has ready to use plugins for mostly platforms like Android, iOS, PHP etc which user can download from Salesforce website and can connect with the platform. But if you want to use SOAP web services directly in your application then you can simply download the WSDL file from salesforce and connect with your application to start accepting data. Today i am going to share a small demo on how to start using Salesforce SOAP web services using a free tool SOAP UI. For your programming language you can check for the best solutions to consume wsdl file.
Steps to consume Salesforce SOAP web services :
- Login to Salesforce and go to Setup from top right corner.
- In Quick Search, search for API.
- Select API option under Build -> Develop.
- Now it will ask you the type of WSDL you want to consume (Enterprise, Partner, Apex, Metadata etc). Enterprise is mostly used for developing application that will consume data from your salesforce instance, partner is used for developing application that will work for multiple organisation etc.
- Select Enterprise for this demo but you can use any as per your requirement. On next page click on Generate button which will download the wsdl file on your system.
- Once done you can open this wsdl file using notepad or any other document reader. The wsdl file looks like :which is basically a XML file containing schema of your objects that is there in your salesforce.
- Now we need to use this wsdl file in SOAP UI application. For that download SOAP UI (https://www.soapui.org/) and install it on your system.
- Create a New SOAP Project from File -> New SOAP Project. In that browse for the wsdl file you downloaded from Salesforce and give a name to this project. Once done click on OK.
- This will create a new project with all the SOAP methods with which user can consume data as per the requirement.
- From the list of methods, we can choose any method that fits our requirement like delete, create, describeSObject, describeAllTabs,query etc. For this demo i am going to use query for running a SOQL Query.
- Before running a SOQL Query we need to authenticate ourself with our salesforce login id and password, for that we need to use login method of wsdl to login. From left side panel, select login request.
- In that Login method we need to pass username, password & security token in body without any header data.
- In the response you will get serverUrl & sessionId which is required for executing wsdl methods to get data from salesforce instance.
- Now let’s start with running a SOQL Query using SOAP API.For this demo I will retrieve Account records from Salesforce Instance. For this we need to use another method of wsdl file that is “Query” which is used to run a query on salesforce.
- In query method request we only need to set sessionId (which we got from login request) in header and in body we need to write SOQL Query in queryString tag which we want to execute. Also the URL to which we are sending request needs to be changed to the serverURL (which we got from login request). Once you execute this, it will give you response will Account records.
Note : I am also sharing one Salesforce Trailhead link for the same (LINK )
Leave a Reply