I have been working with the Salesforce API lately, and have found the learning curve to be a little bit steep. I can’t say it’s been insurmountable, but often times the first day working with any API is the most frustrating.

So without further ado, I present the Minimum Pieces of Flair required to successfully login to the SOAP API.

Steps to add a Web Reference to your project in Visual Studio.

  1. Right Click Project
  2. Add
  3. Service Reference
  4. Advanced…
  5. Add Web Reference…
  6. Open your salesforce wsdl xml file
  7. Click Add Reference

C# code

var service = new SforceService.SforceService();
var result = service.login("user", "password");
service.Url = result.serverUrl;
service.SessionHeaderValue = 
    new SforceService.SessionHeader() 
        sessionId = result.sessionId 

This will get you everything that you need to login and start making calls. Salesforce’s introductory example is lengthy with all kinds of exception handling and timeout setting. In my case, this was overkill, but your mileage may vary.


One thought on “Salesforce SOAP API Login – Minimum Pieces of Flair

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s