SOAP Example 1 (v1): Retrieving the list of accounts for an authenticated user

SOAP Example 1: Retrieving the list of accounts for an authenticated user

(Return to main article: Samples for Java (SOAP) v1)

1. Define login information:

 

private static final String login = "URCHIN_LOGIN";
private static final String password = "URCHIN_PASSWORD";

2. Define a service connection for the AdminService API:

 

AdminserviceStub adminStub = new AdminserviceStub();

3. Define a request for the getAccountList method in the AdminService:

 

AdminserviceStub.GetAccountList accReq = new AdminserviceStub.GetAccountList();

4. Set up the getAccountList request parameters:

 

accReq.setLogin(login);
accReq.setPassword(password);

5. Retrieve the list of available accounts:

 

AdminserviceStub.GetAccountListResponse accRsp = adminStub.getAccountList(accReq);

6. Parse and display the response:

 

      if (accRsp != null){
        AdminserviceStub.GetAccountListResponseSequence [] responseSequence = accRsp.getGetAccountListResponseSequence();
        // Display accounts info
        System.out.println("AdminService::GetAccountList");
        for (AdminserviceStub.GetAccountListResponseSequence account : responseSequence) {
          System.out.print("account id: \"" + account.localAccount.getAccountId() + "\", ");
          System.out.print("account name: \"" + account.localAccount.getAccountName() + "\", ");
          System.out.print("contact name: \"" + account.localAccount.getContactName() + "\", ");
          System.out.print("e-mail: \""  + account.localAccount.getEmailAddress() + "\", ");
          System.out.println("phone number: \"" + account.localAccount.getPhoneNumber() + "\".");
        }
      }

For the complete sample code, see the implementation of GetAccountList() in the AdminService.java file.

(Return to main article: Samples for Java (SOAP) v1)