Thursday, 26 March 2020

Salesforce API SOAP endpoint - SoapUi

Hey all,
so I got to recently try out salesforce API and how to hit them up.
This is a summary of how to do it.
So, the first thing we need to make any call is authentication. I am pretty sure all of you know what is authentication but nonetheless, authentication is basically verification of your identity.
Once we authenticate, we get a session token. This session token can be used to make all other calls.

For authentication, you need username, password and security token.

Step 1: Download WSDL for your organization. Now, this is the file containing the relevant info of your org. There are two different types of WSDL available in salesforce.  It is more specific to your org than Partner WSDL which is a bit more generic.

To generate WSDL -
1. Log in to Salesforce as 'System Administrator' or as a user who has the 'Modify All Data Permission'.
2. Setup > Search for 'API' in the quick find box.
3. Select API.
4. Click Generate Enterprise WSDL.
5. Save the XML WSDL file to your computer.
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_quickstart_get_WSDLs.htm

To make soap calls, you need a soap UI. You can make post calls using postman as well but I have used soap UI. you can download it from here.
https://www.soapui.org/downloads/latest-release.html


Step 2: Once that is done, create a new project and import your WSDL.
Since WSDL is like a MAP to your org, if you changed your org or updated it, for example, created a new custom endpoint in your org, then you need to update this WSDL by downloading and importing it again. So, if you installed a package, then you need to update this as well.





Step 3:  Explore your new project. You will see a lot of new methods in your project. All of them have a sample request call. Update the required info according to each call.

Step 4: Authenticate and use the token to make new calls.
use the login call to authenticate.
Use a password appended with your security token for login.


Step 5: DescibeSobject. This method describes all fields associated with a particular 'SObject'. Use the token obtained in step 4.


Step 6: Query Method. Use the token obtained in step 4.


Step 7: Similarly, you can use the 'create' method to create new SObjects like a case, account in salesforce. Use the token obtained in step 4. I have a custom SObject in my org. Trying to create it.

So, This is brief about testing Salesforce API using SOAP calls.

PS - Stay hydrated. In this season of coronavirus. Maintain social distance but please feel free to reach out to me over the mail in case of doubts.




No comments:

Post a Comment