Dear Jeff, When I tried to run the AccountServiceDemo from the java client library, the following error appeared.
Exception in thread "main" javax.xml.rpc.ServiceException: java.lang.ClassCastException: com.google.api.adwords.v13.AccountServiceSoapBindingStub cannot be cast to com.google.api.adwords.lib.AdWordsService at com.google.api.adwords.lib.BaseCredentials.getService (BaseCredentials.java:178) at main.AccountServiceDemo.main(AccountServiceDemo.java:44) I replaced the default constructor of AdWordsUser() with AdWordsUser user = new AdWordsUser (email,password,userAgent,developerToken,appToken); I do'nt know why the AccountServiceSoapBindingStub can't cast to AdWordsService. Could you please tell me the answer? I'm looking forward to your reply. Thank you. On Mar 11, 11:38 am, PPL <ppl...@gmail.com> wrote: > Thank you very much Jeff. > I'll try to use the Java client library and I'll tell you it works out > or not.. > > Thank you. > > On Mar 10, 11:14 pm, AdWords API Advisor > > > > <adwordsapiadvi...@google.com> wrote: > > If you're just getting started with the AdWords API I'd strongly > > recommend that you make use of the Java client library instead of just > > using the standalone sample code. The client library includes > > instructions on how to download all of the dependencies and has > > examples packaged along with it that illustrate how to create > > campaigns, ad groups, ads, and criteria. > > > The standalone sample code that you're trying to use should work if > > you satisfy the proper dependencies, but it's intended more as a > > reference implementation to show the syntax for a particular API call > > than as something you should build an application around. > > > The Java client library is available from > > > http://code.google.com/p/google-api-adwords-java/ > > > Cheers, > > -Jeff Posnick, AdWords API Team > > > On Mar 10, 7:07 am, PPL <ppl...@gmail.com> wrote: > > > > Hello, > > > I'm new to adwrods. > > > I want to test to create new campaign by using the following sample > > > codes. > > > But when I run it, the following error appeared. > > > > java.lang.NullPointerException > > > at > > > com.google.api.adwords.v13.CampaignServiceSoapBindingStub.addCampaign_aroundBody1$advice > > > (CampaignServiceSoapBindingStub.java:146) > > > at > > > com.google.api.adwords.v13.CampaignServiceSoapBindingStub.addCampaign > > > (CampaignServiceSoapBindingStub.java:1) > > > at main.AddCampaign.main(AddCampaign.java:76) > > > > I'm running in Windows OS. > > > Could u pls help me how to start testing in sand box? > > > With sample codes and procedure will be more helpful. > > > The following is the testing codes. > > > Thanks > > > > import com.google.api.adwords.v13.AdSchedule; > > > import com.google.api.adwords.v13.AdScheduleStatus; > > > import com.google.api.adwords.v13.BudgetPeriod; > > > import com.google.api.adwords.v13.Campaign; > > > import com.google.api.adwords.v13.CampaignInterface; > > > import com.google.api.adwords.v13.CampaignServiceLocator; > > > import com.google.api.adwords.v13.CountryTargets; > > > import com.google.api.adwords.v13.DayOfWeek; > > > import com.google.api.adwords.v13.GeoTarget; > > > import com.google.api.adwords.v13.SchedulingInterval; > > > import org.apache.axis.client.Stub; > > > public class AddCampaign { > > > // Provide AdWords login information. > > > private static final String email = "a...@gmail.com"; > > > private static final String password = "aa"; > > > private static final String clientEmail = > > > "client_1+...@gmail.com"; > > > private static final String useragent = "JJJ: AdWords API Java > > > Sample > > > Code"; > > > private static final String developerToken = > > > "a...@gmail.com++jpy"; > > > private static final String applicationToken = ""; > > > private static final String namespace = > > > "https://sandbox.google.com/ > > > api/adwords/v13"; > > > > public static void main(String[] args) > > > { > > > try > > > { > > > // Set up service connection. > > > CampaignInterface service = new > > > CampaignServiceLocator > > > ().getCampaignService(); > > > // Define SOAP headers. > > > ((Stub) service).setHeader(namespace, "email", > > > email); > > > ((Stub) service).setHeader(namespace, "password", > > > password); > > > ((Stub) service).setHeader(namespace, > > > "clientEmail", > > > clientEmail); > > > ((Stub) service).setHeader(namespace, "useragent", > > > useragent); > > > ((Stub) service).setHeader(namespace, > > > "developerToken", > > > developerToken); > > > ((Stub) service).setHeader(namespace, > > > "applicationToken", > > > applicationToken); > > > // BEGIN CampaignService.addCampaign: v13 > > > // Create new campaign structure with ad > > > scheduling set to show ads > > > on > > > // Monday, Wednesday, and Friday from 8:00am to > > > 5:00pm. Each bid > > > is > > > // multiplied by 1.0. > > > SchedulingInterval intervalMonday = new > > > SchedulingInterval > > > (); > > > intervalMonday.setDay(DayOfWeek.Monday); > > > intervalMonday.setEndHour(17); > > > intervalMonday.setEndMinute(0); > > > intervalMonday.setMultiplier(1.0); > > > intervalMonday.setStartHour(8); > > > intervalMonday.setStartMinute(0); > > > SchedulingInterval intervalWednesday = new > > > SchedulingInterval > > > (); > > > intervalWednesday.setDay(DayOfWeek.Wednesday); > > > intervalWednesday.setEndHour(17); > > > intervalWednesday.setEndMinute(0); > > > intervalWednesday.setMultiplier(1.0); > > > intervalWednesday.setStartHour(8); > > > intervalWednesday.setStartMinute(0); > > > SchedulingInterval intervalFriday = new > > > SchedulingInterval > > > (); > > > intervalFriday.setDay(DayOfWeek.Friday); > > > intervalFriday.setEndHour(17); > > > intervalFriday.setEndMinute(0); > > > intervalFriday.setMultiplier(1.0); > > > intervalFriday.setStartHour(8); > > > intervalFriday.setStartMinute(0); > > > AdSchedule schedule = new AdSchedule(); > > > schedule.setIntervals(new > > > SchedulingInterval[]{intervalMonday, > > > intervalWednesday, intervalFriday}); > > > schedule.setStatus(AdScheduleStatus.Enabled); > > > // Create new campaign structure. > > > Campaign campaign = new Campaign(); > > > campaign.setName("Sample Campaign"); > > > campaign.setBudgetAmount(new Long(100000)); > > > campaign.setBudgetPeriod(BudgetPeriod.Daily); > > > GeoTarget geoTargeting = new GeoTarget(); > > > geoTargeting.setCountryTargets(new > > > CountryTargets(new String[] > > > {"JP"},new String[]{})); > > > campaign.setGeoTargeting(geoTargeting); > > > campaign.setLanguageTargeting(new String[] > > > {"en"}); > > > campaign.setSchedule(schedule); > > > // Add campaign. > > > campaign = service.addCampaign(campaign); > > > // END CampaignService.addCampaign: v13 > > > // Display new campaign. > > > System.out.println("New campaign with name \"" + > > > campaign.getName() > > > + "\" and id \"" + > > > campaign.getId() + "\" was created."); > > > } > > > catch(Exception e) > > > { > > > e.printStackTrace(); > > > } > > > } > > > > }- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en -~----------~----~----~----~------~----~------~--~---