Programing QA

Programing/Developing Questions & Answers. Focus on business application material

Connect to Salesforce partners WebServices (WSDL) Using Visual Studio 2010/2012/2013 & C#. This is complex WCF example. look for the “DOT.NET 2.0 Style” for easier way.

Step 1:

Logon to Salesforce and download the Partners WSDL and save it to your HD. You can get it from “Setup—>Develop—>API”. Make sure to click “save link as”. open the link and then save it will result corrupted WSDL file.


Step 2:

Add reference to the new WSDL inside your project in Visual Studio using “Add new service reference”.


Step 3:

Write the actual code to query the salesforce using C# and WCF.

Code Snippet
  1. // This client instance will b e use to login and get valid password.
  2. SF.SoapClient loginClient = new SF.SoapClient();
  4. SF.LoginScopeHeader header = new SF.LoginScopeHeader(); // not needed in this demo.
  5. SF.CallOptions options = new SF.CallOptions(); // not needed in this demo.
  7. // User this URL for production. you can change the API version id needed.
  8. loginClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(""); // Production
  9. // Use this URL for sandbox.
  10. //client.Endpoint.Address = new System.ServiceModel.EndpointAddress(""); // Sandbox
  12. // Login details - add the token string at the end of the password
  13. SF.LoginResult response = loginClient.login(header, options, "myemail", "mypasswordmytoken");
  15. // The object will hold the session id and required for all future communication with salesforce.
  16. SF.SessionHeader sessionHeader = new SF.SessionHeader();
  17. sessionHeader.sessionId = response.sessionId;
  19. // Now, after we loged in and have session id - we can start new client and use it to query the salesforce
  20. SF.SoapClient executionClient = new SF.SoapClient();
  22. // Here we give our execution client the urk we got from the login call.
  23. executionClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(response.serverUrl);
  25. // object to hold our query result
  26. SF.QueryResult result = new SF.QueryResult();
  28. // Finaly we can query the salesforce. the result will be in the "QueryResult" object.
  29. SF.LimitInfo[] info = executionClient.queryAll(sessionHeader, options, new SF.QueryOptions(), "select id from account", out result);

Comments (1) -

  • Rolande Patil

    7/18/2014 5:05:02 PM |

    hey there and thanks to your information ? I have certainly picked up anything new from proper here. I did then again experience a few technical points the usage of this site, as I experienced to reload the site a lot of instances previous to I may get it to load properly. I have been considering if your web hosting is OK? Not that I am complaining, however slow loading cases occasions will very frequently affect your placement in google and could injury your high quality ranking if advertising and marketing with Adwords. Anyway I'm including this RSS to my e-mail and can look out for a lot extra of your respective exciting content. Ensure that you update this again very soon..

  • My Website

    3/15/2015 7:10:46 AM |

    Great article post.Thanks Again. Want more.

  • Jimmie Lepetich

    3/16/2015 3:42:02 PM |

    I think  you have  observed  some very interesting points ,  regards  for the post.

  • Drew Wells

    3/16/2015 4:04:02 PM |

    Perfectly composed content material, thanks for entropy. "He who establishes his argument by noise and command shows that his reason is weak." by Michel de Montaigne.

  • Porfirio Skotnicki

    3/16/2015 4:09:33 PM |

    It is actually a great and helpful piece of information. I am satisfied that you simply shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

  • Flor Dingee

    3/16/2015 4:14:00 PM |

    Very interesting points  you have  remarked,  regards  for posting . "She had an unequalled gift... of squeezing big mistakes into small opportunities." by Henry James.

  • Kurt Hoffmeyer

    3/16/2015 8:25:15 PM |

    I noticed that ranking your site may be difficult... I had to hire an SEO company to make sure my site stayed at number one. However, it was expensive! It was a constant monthly fee and my company/website was not big enough to afford them. I checked around for a DIY SEO program and <A href=";>found this one</A>. It worked out well because I knew very little about SEO and I only knew have to manage my website. Anyway just thought I'd share some info with everyone. Good luck and don't give up!!!

  • see it here

    3/18/2015 11:02:52 AM |

    I simply want to tell you that I am all new to blogging and site-building and honestly liked you're web page. Probably I’m want to bookmark your blog . You amazingly have amazing stories. Thanks a bunch for sharing your web-site.

Comments are closed