SOAP .NET Example 1: Retrieving the list of accounts for an authenticated user
(Return to main article: Samples for .NET (SOAP) v1)
1. To use the types from the generated class without specifying the namespace, include the namespace as follows:
using SampleCode.com.google.DataAPI.AdminService;
2. Specify login information:
private const string login = "YOUR_LOGIN"; private const string password = "YOUR_PASSWORD";
3. Define a service connection for AdminService API:
adminservice adminService = new adminservice();
4. Execute request:
Account[] accounts = adminService.getAccountList(login, password);
5. Parse and display results:
foreach (Account account in accounts) { Console.Write("Account id is \"" + account.accountId + "\", "); Console.Write("name is \"" + account.accountName + "\", "); Console.Write("contact name is \"" + account.contactName + "\", "); Console.Write("e-mail is \"" + account.emailAddress + "\" "); Console.WriteLine("and phone number is \"" + account.phoneNumber + "\"."); }
Complete sample code for this example is available in the AdminServiceGetAccountListSOAP.cs file.
(Return to main article: Samples for .NET (SOAP) v1)