import java.util.Collections; import java.util.List; import com.google.api.adsense.v2.*; import com.sun.xml.ws.developer.WSBindingProvider; public class JaxwsCreateAccount { static final String developerEmail = "REPLACE WITH DEVELOPER'S EMAIL"; static final String developerPassword = "REPLACE WITH DEVELOPER'S PASSWORD"; public static void main(String args[]) throws Exception { AccountService accountService = new AccountServiceService().getAccountService(); // Set the SOAP headers ObjectFactory fact = new ObjectFactory(); ((WSBindingProvider)accountService).setOutboundHeaders( fact.createDeveloperEmail(developerEmail), fact.createDeveloperPassword(developerPassword), fact.createClientId("ignored")); // create the parameters to createAdSenseAccount String loginEmail = "users_login_here@example.com"; String entityType = "Individual"; String websiteUrl = "http://test.example.com"; String websiteLocale = "en"; String usersPreferredLocale = "en_US"; boolean emailPromotionPreferences = true; List synServiceTypes = Collections.singletonList("ContentAds"); boolean hasAcceptedTCs = true; // call createAdSenseAccount List synServiceData = accountService.createAdSenseAccount(loginEmail, entityType, websiteUrl, websiteLocale, usersPreferredLocale, emailPromotionPreferences, synServiceTypes, hasAcceptedTCs); // extract and print results String synServiceId = synServiceData.get(0).getId(); String synServiceType = synServiceData.get(0).getType(); System.out.println("Just created an AdSense account. This new " + "account has an associated " + synServiceType + " syndication service with id " + synServiceId + "."); } }