Skip to content

Instantly share code, notes, and snippets.

/Program.cs Secret

Created February 21, 2014 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7d533cf2b4822fb29317 to your computer and use it in GitHub Desktop.
Save anonymous/7d533cf2b4822fb29317 to your computer and use it in GitHub Desktop.
Salesforce .NET Developer Environment - Verify WSDL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using VerifyWSDLTest.sforce;
namespace VerifyWSDLTest
{
class Program
{
private static SoapClient client;
private static LoginResult loginResult;
private static bool login()
{
client = new SoapClient();
string acctName = "YOUR DEVORG USERNAME";
string acctPw = "YOUR DEVORG PASSWORD AND SECURITY TOKEN";
try
{
loginResult = client.login(null, acctName, acctPw);
}
catch (Exception e)
{
Console.WriteLine("Unexpected login error: " + e.Message);
Console.WriteLine(e.StackTrace);
return false;
}
return true; // success
}
static void Main(string[] args)
{
if (login())
{
// display some current login settings
Console.Write("Service endpoint: " + loginResult.serverUrl + "\n");
Console.Write("Username: " + loginResult.userInfo.userName + "\n");
Console.Write("SessionId: " + loginResult.sessionId + "\n");
Console.Write("Press any key to continue:\n");
Console.ReadKey();
}
}
}
}
@ceciquin
Copy link

Hi, i'm trying this in VS 2019 and it's not working the reference to "using VerifyWSDLTest.sforce;" and the method "loginResult = client.login(null, acctName, acctPw);"

@chibeze01
Copy link

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using sforce;

namespace VerifyWSDLTest
{
    class Program
    {

        private static SoapClient client;
        private static loginResponse loginResponse;

        private static bool login()
        {

            client = new SoapClient();

            string acctName = "YOUR DEVORG USERNAME";
            string acctPw = "YOUR DEVORG PASSWORD AND SECURITY TOKEN";
            try
            {
                loginRequest lr = new loginRequest(null, acctName, acctPw);
                loginResponse = client.login(lr);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unexpected login error: " + e.Message);
                Console.WriteLine(e.StackTrace);
                return false;
            }
            return true; // success
        }

        static void Main(string[] args)
        {
            if (login())
            {
                // display some current login settings
                Console.Write("Service endpoint: " + loginResponse.result.serverUrl + "\n");
                Console.Write("Username: " + loginResponse.result.userInfo.userName + "\n");
                Console.Write("SessionId: " + loginResponse.result.sessionId + "\n");
                Console.Write("Press any key to continue:\n");
                Console.ReadKey();
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment