Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.ServiceModel;
- using System.Text;
- using System.Threading.Tasks;
- namespace dotnet_CSWSTestClientSimple
- {
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- //get wsdl, username, passwrod from user
- Console.WriteLine("Authentication URL:");
- string url = Console.ReadLine();
- Console.WriteLine("Username:");
- string userName = Console.ReadLine();
- Console.WriteLine("Password:");
- ConsoleKeyInfo key;
- string passWord = "";
- do
- {
- key = Console.ReadKey(true);
- if ((key.Key != ConsoleKey.Backspace) && (key.Key != ConsoleKey.Enter))
- {
- passWord += key.KeyChar;
- Console.Write("*");
- }
- else if (key.Key == ConsoleKey.Backspace)
- {
- if (passWord.Length > 0)
- {
- passWord = passWord.Substring(0, passWord.Length - 1);
- Console.Write("\b");
- }
- }
- }
- while (key.Key != ConsoleKey.Enter);
- Console.WriteLine();
- string userPassword = passWord;
- //authenticate using the url/username/password provided
- OTAuth.AuthenticationClient auth = new OTAuth.AuthenticationClient();
- auth.Endpoint.Address = new EndpointAddress(url);
- string token = auth.AuthenticateUser(userName, userPassword);
- Console.WriteLine("Authentication token: " + token);
- //wait for user to press enter before exiting
- }
- catch (Exception ex)
- {
- Console.WriteLine("Failure! {0}", ex.Message);
- }
- Console.WriteLine("Press enter to continue");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment