daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 14th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {"There was an error in serializing one of the headers in message loginRequest: 'Unable to generate a temporary class (result=1).rnerror CS0030: Cannot convert type 'ForceConsole.PartnerSOAP.ListViewRecordColumn[]' to 'ForceConsole.PartnerSOAP.ListViewRecordColumn'rnerror CS0030: Cannot convert type 'ForceConsole.PartnerSOAP.ListViewRecordColumn[]' to 'ForceConsole.PartnerSOAP.ListViewRecordColumn'rnerror CS0029: Cannot implicitly convert type 'ForceConsole.PartnerSOAP.ListViewRecordColumn' to 'ForceConsole.PartnerSOAP.ListViewRecordColumn[]'rnerror CS0029: Cannot implicitly convert type 'ForceConsole.PartnerSOAP.ListViewRecordColumn' to 'ForceConsole.PartnerSOAP.ListViewRecordColumn[]'rn'.  Please see InnerException for more details."}
  2.    
  3. namespace ForceConsole
  4. {
  5.     using ForceConsole.PartnerSOAP;
  6.     using System;
  7.     using System.ServiceModel;
  8.  
  9.     class Program
  10.     {
  11.         private static SoapClient loginClient; // for login endpoint
  12.         private static SoapClient client; // for API endpoint
  13.         private static SessionHeader header;
  14.         private static EndpointAddress endpoint;
  15.  
  16.         static void Main(string[] args)
  17.         {
  18.             Program sample = new Program();
  19.             sample.run();
  20.         }
  21.  
  22.         public void run()
  23.         {
  24.             // Make a login call
  25.             if (login())
  26.             {
  27.                 // Log out
  28.                 logout();
  29.             }
  30.             Console.ReadLine();
  31.         }
  32.  
  33.         private bool login()
  34.         {
  35.             Console.Write("Enter username: ");
  36.             string username = Console.ReadLine();
  37.             Console.Write("Enter password: ");
  38.             string password = Console.ReadLine();
  39.  
  40.             // Create a SoapClient specifically for logging in
  41.             loginClient = new SoapClient();
  42.  
  43.             // (combine pw and token if necessary)
  44.             LoginResult lr;
  45.             try
  46.             {
  47.                 Console.WriteLine("nLogging in...n");
  48.                 lr = loginClient.login(null, null, username, password); //TODO
  49.             }
  50.             catch (Exception e)
  51.             {
  52.                 // Write the fault message to the console
  53.                 Console.WriteLine("An unexpected error has occurred: " + e.Message);
  54.  
  55.                 // Write the stack trace to the console
  56.                 Console.WriteLine(e.StackTrace);
  57.                 return false;
  58.             }
  59.  
  60.             // Check if the password has expired
  61.             if (lr.passwordExpired)
  62.             {
  63.                 Console.WriteLine("An error has occurred. Your password has expired.");
  64.                 return false;
  65.             }
  66.  
  67.             /** Once the client application has logged in successfully, it will use
  68.              * the results of the login call to reset the endpoint of the service
  69.              * to the virtual server instance that is servicing your organization
  70.              */
  71.  
  72.             // On successful login, cache session info and API endpoint info
  73.             endpoint = new EndpointAddress(lr.serverUrl);
  74.  
  75.             /** The sample client application now has a cached EndpointAddress
  76.             * that is pointing to the correct endpoint. Next, the sample client
  77.             * application sets a persistent SOAP header that contains the
  78.             * valid sessionId for our login credentials. To do this, the sample
  79.             * client application creates a new SessionHeader object. Add the session
  80.             * ID returned from the login to the session header
  81.             */
  82.             header = new SessionHeader();
  83.             header.sessionId = lr.sessionId;
  84.  
  85.             // Create and cache an API endpoint client
  86.             client = new SoapClient("Soap", endpoint);
  87.  
  88.             printUserInfo(lr, lr.serverUrl);
  89.  
  90.             // Return true to indicate that we are logged in, pointed  
  91.             // at the right URL and have our security token in place.
  92.             return true;
  93.         }
  94.  
  95.         private void printUserInfo(LoginResult lr, String authEP)
  96.         {
  97.             try
  98.             {
  99.                 GetUserInfoResult userInfo = lr.userInfo;
  100.  
  101.                 Console.WriteLine("nLogging in ...n");
  102.                 Console.WriteLine("UserID: " + userInfo.userId);
  103.                 Console.WriteLine("User Full Name: " +
  104.                     userInfo.userFullName);
  105.                 Console.WriteLine("User Email: " +
  106.                     userInfo.userEmail);
  107.                 Console.WriteLine();
  108.                 Console.WriteLine("SessionID: " +
  109.                     lr.sessionId);
  110.                 Console.WriteLine("Auth End Point: " +
  111.                     authEP);
  112.                 Console.WriteLine("Service End Point: " +
  113.                     lr.serverUrl);
  114.                 Console.WriteLine();
  115.             }
  116.             catch (Exception e)
  117.             {
  118.                 Console.WriteLine("An unexpected error has occurred: " + e.Message +
  119.                     " Stack trace: " + e.StackTrace);
  120.             }
  121.         }
  122.  
  123.         private void logout()
  124.         {
  125.             try
  126.             {
  127.                 client.logout(header, null); //TODO
  128.                 Console.WriteLine("Logged out.");
  129.             }
  130.             catch (Exception e)
  131.             {
  132.                 // Write the fault message to the console
  133.                 Console.WriteLine("An unexpected error has occurred: " + e.Message);
  134.  
  135.                 // Write the stack trace to the console
  136.                 Console.WriteLine(e.StackTrace);
  137.             }
  138.         }
  139.     }
  140. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top