+ Start a Discussion
Dan Albrecht 5Dan Albrecht 5 

How to login through vb.net

Hey Developer community.  I am having trouble building out my app in .NET.  I have downloaded the WSDL, added the reference to the project and then when I try to implement the sample code, I run into problems.  Does anyone have some good sample code I can look at for reference.  I have done some digging on my own but every sample I run, it doesnt seem to work.  

I can write it in C# or VB.net or convert between the two but the WSDL when it is created for some reason doesn't seem to work.  Any suggestions or guidance the community might have would be helpful.  Thanks
 
Aslam ChaudharyAslam Chaudhary
SFService.SforceService SfdcBinding = null;
LoginResult CurrentLoginResult = null;
SfdcBinding = new SFService.SforceService();
SfdcBinding.Url = con.URL;
CurrentLoginResult = SfdcBinding.login(con.Username, con.Password + con.SecurityToken);

SfdcBinding.Url = CurrentLoginResult.serverUrl;
SfdcBinding.SessionHeaderValue = new SessionHeader();
SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId;
SfdcBinding.Timeout = 60000;

Hope this will help! 
Dan Albrecht 5Dan Albrecht 5
Thanks.  My issue is that when I bring in the WSDL to Visual Studio, make reference to it on the project and then try to use it, I dont see the SforceService.


For example:  I bring in SFService as my connected service.  I then I try to (in vb.net) Dim SfdcBinding as SFService.SforceService, I am not given SforceService as being recognized. 

Do we think there is a problem with the WSDL?

I think this is the true reason I cannot get this to work.  
Dan Albrecht 5Dan Albrecht 5
Ok so I was able to bring in Sforceservice by making a Web Reference.  In your code you list out "con"

What is con?  
Aslam ChaudharyAslam Chaudhary
con is my wrapper class in .Net 

Replace
con.URL to https://login.salesforce.com/services/Soap/u/34.0  (You can update API version to latest I have used 34.0)
and I hope below is self explanatory to you.
con.Username, con.Password + con.SecurityToken.

Please choose the best answer which one helps to you. Let me know if you need any help.