public static void runExample(
DfaServices dfaServices, DfaSession session, String campaignName, long advertiserId,
String url, String landingPageName) throws Exception {
// Request the campaign service from the service client factory.
CampaignRemote campaignService = dfaServices.get(session, CampaignRemote.class);
// Create the campaign structure.
Campaign campaign = new Campaign();
campaign.setId(0);
campaign.setName(campaignName);
campaign.setAdvertiserId(advertiserId);
// Create and set a default landing page.
LandingPage defaultLandingPage = new LandingPage();
defaultLandingPage.setId(0);
defaultLandingPage.setName(landingPageName);
defaultLandingPage.setUrl(url);
campaign.setDefaultLandingPageId(campaignService.saveLandingPage(
defaultLandingPage).getId());
// Set the campaign start date. This example uses today's date.
Calendar startDate = Calendar.getInstance();
campaign.setStartDate(startDate);
// Set the campaign end date. This example uses one month from today's date.
Calendar endDate = Calendar.getInstance();
endDate.add(Calendar.MONTH, 1);
campaign.setEndDate(endDate);
// Save the campaign.
CampaignSaveResult campaignSaveResult = campaignService.saveCampaign(campaign);
// Display the new campaign ID.
System.out.printf("Campaign with ID \"%s\" was created.%n", campaignSaveResult.getId());
}