As publicized, Salesforce (Force.com or SFDC) is Number one on-demand CRM and is as of now an exceptionally hot innovation in the IT industry. Through SOAP APIs, Salesforce firmly coordinates with different back-end innovations like .NET and JAVA, which gives you, a chance to access as well as control your information and usefulness in the Force.com cloud.
The Force.com stage firmly coordinates with Microsoft .NET innovations by means of the Force.com SOAP API, which gives you, a chance to access as well as control your information and usefulness in the Force.com cloud. This usefulness can be executed on any Microsoft.NET supported platform including but not restricted to web applications running IIS, Windows work area or server applications, SharePoint administrations, and SQL Server Programmability.
Today, we will see how can we integrate Salesforce with the Asp.net.
Prerequisites
To do any activity we need appropriate session login to Salesforce application and for which an Enterprise WSDL should be produced through which we will verify ourselves in Salesforce to do our tasks. There are three kinds of WSDL types from which Enterprise WSDL will be of our utilization.
Here are the steps that you need to follow to integrate Salesforce with Asp.net-
WSDLs are consequently produced and kept up by the platform. Whatever objects we are making in Salesforce it will be consequently accessible to accompanying WSDL. Moreover, in the event that we are making any web service classes, its WSDL would also be accessible. To get it we can pursue the underneath steps: –
Go to the standard User Interface, get signed in and explore as beneath, Setup then goes to Setup then choose Develop and then pick API.
Pick the suitable WSDL and download the file to an area available to your improvement condition. Or on the other hand, if suitable WSDL expected isn’t there then do as beneath:- Login then go to Setup then to Develop then API and lastly, Click on ‘Produce’ Now we have the WSDL URL to be utilized further.
Visual Studio 2008 and newer now reference ‘Add Service Reference’ to projects and have deprecated the ‘Add Web Reference’ term. Regardless of terminology or versions, the steps to add a reference to your WSDL file are in essence the same across all versions of Visual Studio:
Visual Studio 2008 and a more up to date reference ‘Add Service Reference’ to ventures and have censured the ‘Add Web Reference’ term. Notwithstanding wording or forms, the means to add a reference to your WSDL document are basically the same all over the adaptations of Visual Studio:
To do any task, first of all, we require a functioning session to the Salesforce API being built up. For this, we require three things as specified beneath:-
We can change the Security token through the Salesforce UI. Changing secret key consequently sends another security token to the email address on the client’s Salesforce record or client can do the same utilizing Salesforce interface resetting of a security password.
The security token is valid only until when a client does the underneath activities:-
Tap on the Username on right most corner of the page >> My Settings >> Personal >> Reset My Security Token. It will reset and make another security token for you which can be utilized for verification in .Net application by connecting with a login password.
Step IV (Authenticate and Create Salesforce API Session in .Net)
Here is the code you need to type in
// to store session variable name
private string _username = "salesforce account username";
// to store session variable name
private string _password = "salesforce account password";
// generated tokenid from salesforce
private const string _tokenID = "token id";
// to store session variable name
private string _sessionId;
// next login time
private DateTime _nextLoginTime;
// instance for login result
Private LoginResult _loginResult;
// instance creation for SforceService
Private SforceService _sForceRef;
// this is a method used to check if the session is valid or not by checking with
// the session variable name
private bool IsValidSession()
{
bool blnResult = false;
if (!string.IsNullOrEmpty(_sessionId) & _sessionId != null)
{
if (DateTime.Now > _nextLoginTime)
blnResult = false;
else
blnResult = true;
}
else
blnResult = false;
return blnResult;
}
}
Call the login technique by passing username and password but password ought to be a blend of salesforce client account password and the security token. Ex:
_loginResult = _sForceRef.login(_username, _password + _tokenID);
Get session details from login result and store it into the session factors. Ex:-
_sessionId = _loginResult.sessionId;
Session["SessionId"] = _loginResult.sessionId;
Session["ServerUrl"] = _loginResult.serverUrl;
Session["NextLoginTime"] = DateTime.Now;
iii) Thereafter you need to launch a proper force.com session to do any supplementary operations
_sForceRef.Url = _loginResult.serverUrl;
_sForceRef.SessionHeaderValue = new SessionHeader();
_sForceRef.SessionHeaderValue.sessionId = _sessionId;
You need to see if the present session is valid and create if not valid. Ex:-
if (!IsValidSession())
isError = GetSessionDetails();
Conclusion
Salesforce and Asp.net integration is not a very difficult thing to do if you follow the steps given above diligently. You just need to make sure that the person who is in charge of the integration process knows some basic coding. This is because at certain places you need to run the codes as you must have already understood from the step IV of the integration process.
Stop, read and acquire deep insights into complex issues
Write a Comment