public static void runExample(DfaServices dfaServices, DfaSession session) throws Exception {
// Request the advertiser service from the service client factory.
AdvertiserRemote advertiserService = dfaServices.get(session, AdvertiserRemote.class);
// Create advertiser search criteria structure.
AdvertiserSearchCriteria advSearchCriteria = new AdvertiserSearchCriteria();
advSearchCriteria.setPageSize(100);
// When paging, start counting page numbers from 1 rather than 0.
advSearchCriteria.setPageNumber(1);
AdvertiserRecordSet advertiserRecordSet;
int i = 1;
do {
// Get advertisers by criteria.
advertiserRecordSet = advertiserService.getAdvertisers(
advSearchCriteria);
for (Advertiser result : advertiserRecordSet.getRecords()) {
System.out.printf("%s) Advertiser with name \"%s\", ID \"%s\", and spotlight " +
"configuration ID \"%s\" was found.%n", i++, result.getName(), result.getId(),
result.getSpotId());
}
advSearchCriteria.setPageNumber(advSearchCriteria.getPageNumber() + 1);
} while (advSearchCriteria.getPageNumber() <= advertiserRecordSet.getTotalNumberOfPages());
System.out.printf("Number of results found: %s%n",
advertiserRecordSet.getTotalNumberOfRecords());
}