Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  2. <s:Header>
  3. <a:Action s:mustUnderstand="1">http://www.ultipro.com/services/loginservice/ILoginService/Authenticate</a:Action>
  4. <h:ClientAccessKey xmlns:h="http://www.ultipro.com/services/loginservice">CAK</h:ClientAccessKey>
  5. <h:Password xmlns:h="http://www.ultipro.com/services/loginservice">PASSWORD</h:Password>
  6. <h:UserAccessKey xmlns:h="http://www.ultipro.com/services/loginservice">USER API KEY</h:UserAccessKey>
  7. <h:UserName xmlns:h="http://www.ultipro.com/services/loginservice">USERNAME</h:UserName>
  8. </s:Header>
  9. <s:Body>
  10. <TokenRequest xmlns="http://www.ultipro.com/contracts" />
  11. </s:Body>
  12. </s:Envelope>
  13.  
  14. namespace ConsoleSample
  15. {
  16. using System;
  17. using System.ServiceModel;
  18. using System.ServiceModel.Channels;
  19.  
  20. using ConsoleSample.LoginService;
  21.  
  22. public class Program
  23. {
  24. internal static void Main(string[] args)
  25. {
  26. // Setup your user credentials:
  27. const string UserName = "";
  28. const string Password = "";
  29. const string UserApiKey = "";
  30. const string CustomerApiKey = "";
  31.  
  32. // Create a proxy to the login service:
  33. var loginClient = new LoginServiceClient("WSHttpBinding_ILoginService");
  34.  
  35. try
  36. {
  37. // Submit the login request to authenticate the user:
  38. string message;
  39. string authenticationToken;
  40.  
  41. AuthenticationStatus loginRequest =
  42. loginClient
  43. .Authenticate(
  44. CustomerApiKey,
  45. Password,
  46. UserApiKey,
  47. UserName,
  48. out message,
  49. out authenticationToken);
  50.  
  51. if (loginRequest == AuthenticationStatus.Ok)
  52. {
  53. // User is authenticated and the authentication token is provided.
  54. Console.WriteLine("User authentication successful.");
  55. }
  56. else
  57. {
  58. // User authentication has failed. Review the message for details.
  59. Console.WriteLine("User authentication failed: " + message);
  60. }
  61.  
  62. loginClient.Close();
  63.  
  64. Console.WriteLine("Press a key to exit...");
  65. Console.ReadKey(true);
  66. }
  67. catch (Exception ex)
  68. {
  69. Console.WriteLine("Exception: " + ex);
  70. loginClient.Abort();
  71. throw;
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement