public static void main(String[] args) throws Exception {
// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the CompanyService.
CompanyServiceInterface companyService =
user.getService(DfpService.V201306.COMPANY_SERVICE);
// Initialize the root logger so that all messages do not filter up.
DfpServiceLogger.initRootLogger();
// Log the incoming and outgoing XML to System.out;
DfpServiceLogger.logToStream(DfpServiceLogger.SOAP_XML_LOG, System.out);
// Fake an exception to test logger which will not work yet.
DfpServiceLogger.DFP_API_LIB_LOG.error("Error in the library.",
new NullPointerException());
// Log errors of the DFP library to System.err.
DfpServiceLogger.logToStream(DfpServiceLogger.DFP_API_LIB_LOG, System.err, Level.ERROR);
// Fake an exception to test logger which will work now.
DfpServiceLogger.DFP_API_LIB_LOG.error("Error in the library.", new NullPointerException());
// Get companies by filter.
CompanyPage page = companyService.getCompaniesByStatement(new Statement("LIMIT 1", null));
if (page.getResults() != null) {
int i = page.getStartIndex();
for (Company company : page.getResults()) {
System.out.println(i + ") Company with ID \"" + company.getId()