Hi PPL,

I copied your code to try it out.
The first error I get is: Exception in thread "main"
java.lang.ClassCastException:
com.google.api.adwords.v12.AccountServiceSoapBindingStub

This happens because I have imported the v13 classes and it is trying
to cast to v12. To fix this either switch to v12 (which you shouldn't
do because that version is no longer supported) or provide the code
with an explicit version. I assume this will be fixed in future
version of the toolkit. As far as I can see there are two AdWordsUser
constructors that support version directly, and otherwise you will
need to use a map with certain string-value pairs:

AdWordsUser user = new AdWordsUser
(email,password,userAgent,developerToken,appToken, "v13", null);

However you are now communicating with the production servers and not
with the sandbox as you indicated you wanted in the subject title. The
sandbox requires the clientid header to be set, and requires an
alternate url.

The complete call to create an adwords user object would now be:

AdWordsUser user = new AdWordsUser(email, password, clientEmail,
userAgent, developerToken, appToken, "v13", new URL("https://
sandbox.google.com"));

The rest of your code should work, however while testing I'm getting
an error with code 0 meaning the sandbox is currently not working
properly. So I can't test your code further. Also your clientEmail
string is malformed it should be [email protected]

On 12 mrt, 10:56, PPL <[email protected]> wrote:
> Dear Jaap,
>
> Could you please send me the small working code(project) of that API,
> if possible?
> I'm facing the same error when I test other services.
> I want to know the usage of those services.
> Otherwise I can't even step further.
> :(
>
> Thank you.
>
> On Mar 12, 5:30 pm, PPL <[email protected]> wrote:
>
> > Dear Jaap,
>
> > Thank you very much for your suggesstion.
> > Below is my code.
>
> > public static void main(String args[]) throws Exception {
> >        // Get credentials and service
> >           String email="[email protected]";
> >           String password="aaaaa";
> >           String userAgent="JIT";
> >           String clientEmail="[email protected]";
> >           String developerToken="[email protected]++jpy";
> >           String appToken="";
> >           // Get credentials and service
>
> >             AdWordsUser user = new AdWordsUser
> > (email,password,userAgent,developerToken,appToken);
>
> >             AccountInterface service =
> >                 (AccountInterface) user.getService(user.ACCOUNT_SERVICE);
>
> >             // Diplays the account's name, timezone, language, and currency.
> >             AccountInfo info = service.getAccountInfo();
>
> >     System.out.println("Account name is \"" + info.getDescriptiveName
> > ()
> >         + "\", id is \"" + info.getCustomerId() + "\", timezone is \""
> >         + info.getTimeZoneId() + "\", language is \""
> >         + info.getLanguagePreference() + "\", and currency is \""
> >         + info.getCurrencyCode() + "\".");
> >   }
>
> > But I still got the same error.
> > I've already import all of the dependencies according to the Readme of
> > java client library.
> > Could you please point out the source of the error?
>
> > Thank you.
>
> > On Mar 12, 4:18 pm, Jaap <[email protected]> wrote:
>
> > > Hi PPL,
>
> > > According to the google adwords API, AccountServiceSoapBindingStub
> > > extends org.apache.axis.client.Stub, and implements AccountInterface.
> > > The ClassCastException occurs because you are try to cast to a class
> > > which is not implemented nor extended by
> > > AccountServiceSoapBindingStub. Presumably you got the service by doing
> > > something like this:
> > > AdWordsService service = (AdWordsService)user.getService
> > > (AdWordsUser.ACCOUNT_SERVICE);
>
> > > This should be
> > > AccountInterface interface = (AccountInterface)user.getService
> > > (AdWordsUser.ACCOUNT_SERVICE);
>
> > > The interface can be used to communicate with the API.
>
> > > Hope this helps.
>
> > > On 12 mrt, 03:38, PPL <[email protected]> wrote:
>
> > > > Hi anybody,
>
> > > > Could you please help me to find out the answer of that error?
>
> > > > 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 can't even step forward cause of it.
>
> > > > I'm looking forward to you.
> > > > Thank you.
>
> > > > On Mar 11, 1:12 pm, PPL <[email protected]> wrote:
>
> > > > > 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 <[email protected]> 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
>
> > > > > > <[email protected]> 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 <[email protected]> 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_aroun­­­­­dBody1$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 = "[email protected]";
> > > > > > > >         private static final String password = "aa";
> > > > > > > >         private static final String clientEmail =
> > > > > > > > "[email protected]";
> > > > > > > >         private static final String useragent = "JJJ: AdWords 
> > > > > > > > API Java Sample
> > > > > > > > Code";
> > > > > > > >         private static final String developerToken = 
> > > > > > > > "[email protected]++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
> > > > > > > > ();
> > > > > > > >                        
>
> ...
>
> meer lezen »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/adwords-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to