API V3 and Axis

31 views
Skip to first unread message

Alejandro Vera

unread,
Jan 29, 2009, 8:33:01 AM1/29/09
to AdSense API Forum
Hello everybody!!!

I am trying to build the v3 stubs using axis (1.2RC1 and 1.4) but I
always get the following error

[axis-wsdl2java] java.io.IOException: ERROR: Missing <soap:fault>
element inFault "associateAccountFault" in operation
"associateAccountFault", in binding associateAccount
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.faultsFromSOAPFault
(SymbolTable.java:2858)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings
(SymbolTable.java:2549)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
744)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.add
(SymbolTable.java:543)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
518)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
495)
[axis-wsdl2java] at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run
(Parser.java:361)
[axis-wsdl2java] at java.lang.Thread.run(Thread.java:619)

In the API page http://code.google.com/intl/es-AR/apis/adsense/developer/adsense_api_samples.html
there are examples of how to do it with java and axis for v2.. but in
v3 there is no samples and no explanations... in another thread i read
something about axis not being supported.. is that right? if that so..
how is suppose to be the upgrade path to v3 for java developers??

Thanks to all..

PD: my native language is spanish. sorry

adsenseapi-...@google.com

unread,
Jan 29, 2009, 2:19:28 PM1/29/09
to AdSense API Forum
Alejandro,

It looks like you're using Axis1 to parse the WSDLs; you will need to
use Axis2 (available at http://ws.apache.org/axis2/download.cgi) for
v3 of the API. Specifically, I've tested with Axis2 v1.4 and have not
encountered problems generating stubs. My command line invocation
looks like this:

./wsdl2java.sh -uri https://sandbox.google.com/api/adsense/v3/AccountService?wsdl

Let me know if that doesn't help.

Cheers,
Wes
AdSense API
> In the API pagehttp://code.google.com/intl/es-AR/apis/adsense/developer/adsense_api_...

Alejandro Vera

unread,
Jan 29, 2009, 3:44:38 PM1/29/09
to AdSense API Forum
Hello

Thanks for your help.. now is working :D

only a question remains. in the old pages there was the examples that
shows to do the following

((Stub) accountService).setHeader(apiNS, "developer_email",
developerEmail);
((Stub) accountService).setHeader(apiNS, "developer_password",
developerPassword);
((Stub) accountService).setHeader(apiNS, "client_id",
"ignored");



But now in axis2 Stub does not have a setHeader method.. wich is the
new way to set this parameters????

thanks in advance

On 29 ene, 16:19, adsenseapi-supportt...@google.com wrote:
> Alejandro,
>
> It looks like you're using Axis1 to parse the WSDLs; you will need to
> use Axis2 (available athttp://ws.apache.org/axis2/download.cgi) for
> v3 of the API.  Specifically, I've tested with Axis2 v1.4 and have not
> encountered problems generating stubs.  My command line invocation
> looks like this:
>
> ./wsdl2java.sh -urihttps://sandbox.google.com/api/adsense/v3/AccountService?wsdl

adsenseapi-...@google.com

unread,
Jan 29, 2009, 9:38:14 PM1/29/09
to AdSense API Forum
Alejandro,

It looks like you'll have to access the _serviceClient object in the
stub and use one of its addHeader methods to build the correct headers
for your calls. These links seem to have some info on how to
generically accomplish that:

http://wso2.org/library/327
http://www.keith-chapman.org/2008/10/axis2-adding-custom-soap-headers-to.html
http://ws.apache.org/axis2/1_4_1/api/org/apache/axis2/client/ServiceClient.html

Let me know if you need some more help.

Cheers,
Wes
AdSense API

Alejandro Vera

unread,
Jan 30, 2009, 7:17:49 AM1/30/09
to AdSense API Forum
Thanks again wes...

I am reading the docs right now..

only that is strange that in the past there were examples for java
like "how to ask for a report" but no anymore... also i noticed that
with axis1 you used methods like service.createAccount(param1,
param2, param3) and now i found that you must create object with the
parameters.. like this

V3AccountServiceStub accountservice = new V3AccountServiceStub();
CreateAccount account = new V3AccountServiceStub.CreateAccount();
account.setLoginEmail("lo...@email.com");
accountservice.createAccount(account);

Is this the new form? i like nothing in the official docs of V3...

Thanks :D


On 29 ene, 23:38, adsenseapi-supportt...@google.com wrote:
> Alejandro,
>
> It looks like you'll have to access the _serviceClient object in the
> stub and use one of its addHeader methods to build the correct headers
> for your calls.  These links seem to have some info on how to
> generically accomplish that:
>
> http://wso2.org/library/327http://www.keith-chapman.org/2008/10/axis2-adding-custom-soap-headers...http://ws.apache.org/axis2/1_4_1/api/org/apache/axis2/client/ServiceC...

Alejandro Vera

unread,
Jan 30, 2009, 11:50:30 AM1/30/09
to AdSense API Forum
Also I found another strange thing.

When i get the wsdl from the sandbox, the stubs are generated using
http://www.google.com/api/adsense/v3 instead of the old https://sandbox.google.com
url.

when i try to go to www.google.com/api/adsense/v3 redirects me (in
firefox) to httpS://www.google.com/api/adsense/v3 and then shows me a
ssl certificade error

(Error code: ssl_error_bad_cert_domain)

Do you know what i am doing wrong??

Thank wes

On 30 ene, 09:17, Alejandro Vera <alejandro.v...@gmail.com> wrote:
> Thanks again wes...
>
> I am reading the docs right now..
>
> only that is strange that in the past there were examples for java
> like "how to ask for a report" but no anymore... also i noticed that
> with axis1 you used methods like  service.createAccount(param1,
> param2, param3) and now i found that you must create object with the
> parameters.. like this
>
> V3AccountServiceStub accountservice = new V3AccountServiceStub();
> CreateAccount account = new V3AccountServiceStub.CreateAccount();
> account.setLoginEmail("lo...@email.com");
> accountservice.createAccount(account);
>
> Is this the new form? i like nothing in the official docs of V3...
>
> Thanks  :D
>
> On 29 ene, 23:38, adsenseapi-supportt...@google.com wrote:
>
> > Alejandro,
>
> > It looks like you'll have to access the _serviceClient object in the
> > stub and use one of its addHeader methods to build the correct headers
> > for your calls.  These links seem to have some info on how to
> > generically accomplish that:
>
> >http://wso2.org/library/327http://www.keith-chapman.org/2008/10/axis2......

adsenseapi-...@google.com

unread,
Jan 30, 2009, 2:44:39 PM1/30/09
to AdSense API Forum
Alejandro,

That url just corresponds to the namespace that the wsdl is using. It
just so happens that both the sandbox and production utilize the same
namespace. The endpoint for stubs generated from the sandbox wsdls
should still be https://sandbox.google.com/api/adsense/v3/... when
using the default constructor.

Lastly, it looks like you're on the right track with regards to your
above code. I apologize for the lack of java samples; I'll see if I
can't get a few available for next week.

Cheers,
Wes
AdSense API

On Jan 30, 8:50 am, Alejandro Vera <alejandro.v...@gmail.com> wrote:
> Also I found another strange thing.
>
> When i get the wsdl from the sandbox, the stubs are generated usinghttp://www.google.com/api/adsense/v3instead of the oldhttps://sandbox.google.com
> url.
>
> when i try to go towww.google.com/api/adsense/v3redirects me (in
> firefox) to  httpS://www.google.com/api/adsense/v3and then shows me a

Alejandro Vera

unread,
Feb 2, 2009, 7:04:10 AM2/2/09
to AdSense API Forum
Wes, thanks for the help.. but still no luck

the "localhost:1234" in the logs earlier was me using tcpmon to look
in the xml

I am going to write down all the options i am using

I generate the stubs using the line you give me

./wsdl2java.sh -uri https://sandbox.google.com/api/adsense/v3/AccountService?wsdl

Then, in the stub I change all the "http://www.google.com" for
"https://sandbox.google.com"

The I use this code

V3AccountServiceStub stub = new V3AccountServiceStub();
ServiceClient client = stub._getServiceClient();
client.addStringHeader(new QName(SystemConstants.ADSENSE_NS_V3,
"developer_email"), SystemConstants.ADSENSE_API_EMAIL );
client.addStringHeader(new QName(SystemConstants.ADSENSE_NS_V3,
"developer_password"), SystemConstants.ADSENSE_API_PASSWORD);

client.addStringHeader(new QName(SystemConstants.ADSENSE_NS_V3,
"debug_association_type"), "Active");
client.addStringHeader(new QName(SystemConstants.ADSENSE_NS_V3,
"debug_zip"),"123456");
client.addStringHeader(new QName(SystemConstants.ADSENSE_NS_V3,
"debug_phone"), "5622321852");
client.addStringHeader(new QName(SystemConstants.ADSENSE_NS_V3,
"client_id"), "ignored");

stub.createAccount(new V3AccountServiceStub.CreateAccount());


The namespace is "http://www.google.com/api/adsense/v3"

And still have the same problem..

So...

1) namespace must be "http://www.google.com/api/adsense/v3" in the
sandbox and in production?
2) The stubs are being generated with "http://www.google.com". I ok to
replace them with sandbox?? if so, with https or http (the original is
without https)?


Thanks again for your patience wes

On 30 ene, 16:44, adsenseapi-supportt...@google.com wrote:
> Alejandro,
>
> That url just corresponds to the namespace that the wsdl is using.  It
> just so happens that both the sandbox and production utilize the same
> namespace.  The endpoint for stubs generated from the sandbox wsdls
> should still behttps://sandbox.google.com/api/adsense/v3/... when
> using the default constructor.
>
> Lastly, it looks like you're on the right track with regards to your
> above code.  I apologize for the lack of java samples; I'll see if I
> can't get a few available for next week.
>
> Cheers,
> Wes
> AdSense API
>
> On Jan 30, 8:50 am, Alejandro  Vera <alejandro.v...@gmail.com> wrote:
>
> > Also I found another strange thing.
>
> > When i get the wsdl from the sandbox, the stubs are generated usinghttp://www.google.com/api/adsense/v3insteadof the oldhttps://sandbox.google.com
> > url.
>
> > when i try to go towww.google.com/api/adsense/v3redirectsme (in
> > firefox) to  httpS://www.google.com/api/adsense/v3andthen shows me a

Alejandro Vera

unread,
Feb 2, 2009, 8:35:21 AM2/2/09
to AdSense API Forum
Hello Wes.. I have new information....

Using apache tcpmon I found the problem

The stubs being generated start with

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-
envelope">
<soapenv:Header>

If I use them (sending it via tcpmon) google returns me a Internal
error 500

If i replace them using the example in the page using

<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Header>

Then google gives me a <faultstring>Login with this username/password
failed.</faultstring>

So the problem is the generated xml. Im am using axis2 1.4.1.. can be
it the problem?

And reading this error seems that my username password doesnt works..
how can i test if they are right?

Thanks again Wes

On 2 feb, 09:04, Alejandro Vera <alejandro.v...@gmail.com> wrote:
> Wes, thanks for the help.. but still no luck
>
> the "localhost:1234" in the logs earlier was me using tcpmon to look
> in the xml
>
> I am going to write down all the options i am using
>
> I generate the stubs using the line you give me
>
> ./wsdl2java.sh -urihttps://sandbox.google.com/api/adsense/v3/AccountService?wsdl
> > > When i get the wsdl from the sandbox, the stubs are generated usinghttp://www.google.com/api/adsense/v3insteadofthe oldhttps://sandbox.google.com
> > > url.
>
> > > when i try to go towww.google.com/api/adsense/v3redirectsme(in
> > > firefox) to  httpS://www.google.com/api/adsense/v3andthenshows me a

adsenseapi-...@google.com

unread,
Feb 3, 2009, 8:16:09 PM2/3/09
to AdSense API Forum
Alejandro,

It looks like Axis2 v1.4's wsdl2java implementation automatically
generates SOAP 1.2 bindings for the service; these appear to be
slightly incompatible--at least, with respect to faults--with our
service, so I suggest you use either the '-ap' or '-pn v3/$
{SERVICENAME}SOAP11port_https' (where ${SERVICENAME} is similar to
AccountService, etc.) flags to generate SOAP 1.1 bindings. For
reference, my command looks like this:
./axis2-1.4.1/bin/wsdl2java.sh -p
com.google.api.adsense.v3.AccountService -ap -uri
https://sandbox.google.com/api/adsense/v3/AccountService?wsdl

After generating stubs for the AccountService, I wrote a short
(relatively speaking) java sample to call the CreateAccount method,
which I've appended below. I'm sure the formatting is going to get
messed up, but I hope you can get the idea. I'll write a few more and
then get them up under our sample code section.

// Copyright 2009 Google Inc. All Rights Reserved.

package com.google.api.adsense.v3.SampleCode;

import com.google.api.adsense.v3.AccountService.CreateAccountFault;
import
com.google.api.adsense.v3.AccountService.V3AccountServicev3AccountServiceSOAP11Port_httpsStub;
import
com.google.api.adsense.v3.AccountService.V3AccountServicev3AccountServiceSOAP11Port_httpsStub.SyndicationService_Data;

import org.apache.axis2.client.ServiceClient;
import org.apache.axiom.om.OMElement;

import java.util.Iterator;
import javax.xml.namespace.QName;

/**
* Sample code for calling AdSense API v3's CreateAccount method.
*
* @author adsenseapi-...@google.com (Wes Goodman)
*/
public class CreateAccountSample {
static final String DEVELOPER_EMAIL = "DEVELOPER_EMAIL";
static final String DEVELOPER_PASS = "DEVELOPER_PASS";
static final String ADSENSE_V3_NS = "http://www.google.com/api/
adsense/v3";

/**
* @param args
*/
public static void main(String[] args) {
try {
V3AccountServicev3AccountServiceSOAP11Port_httpsStub
account_service = new
V3AccountServicev3AccountServiceSOAP11Port_httpsStub();
ServiceClient service_client = account_service._getServiceClient
();
service_client.addStringHeader(new QName(ADSENSE_V3_NS,
"developer_email"), DEVELOPER_EMAIL);
service_client.addStringHeader(new QName(ADSENSE_V3_NS,
"developer_password"), DEVELOPER_PASS);



V3AccountServicev3AccountServiceSOAP11Port_httpsStub.CreateAccount
account_msg = new
V3AccountServicev3AccountServiceSOAP11Port_httpsStub.CreateAccount();
account_msg.setLoginEmail("USER'S_LOGIN_EMAIL");

V3AccountServicev3AccountServiceSOAP11Port_httpsStub.EntityType
entity_type = new
V3AccountServicev3AccountServiceSOAP11Port_httpsStub.EntityType();
entity_type.setValue("Individual");
account_msg.setEntityType(entity_type);

account_msg.setWebsiteUrl("www.PLACEHOLDER_URL.org");
account_msg.setWebsiteLocale("en");
account_msg.setUsersPreferredLocale("en_US");
account_msg.setEmailPromotionsPreference(false);


V3AccountServicev3AccountServiceSOAP11Port_httpsStub.SyndicationService_Type
synservice_type = new
V3AccountServicev3AccountServiceSOAP11Port_httpsStub.SyndicationService_Type
();
synservice_type.setValue("ContentAds");
account_msg.addSynServiceTypes(synservice_type);

account_msg.setDeveloperUrl("code.google.com");


V3AccountServicev3AccountServiceSOAP11Port_httpsStub.CreateAccountResponse
response = account_service.createAccount(account_msg);


V3AccountServicev3AccountServiceSOAP11Port_httpsStub.SyndicationService_Data
[] synservice_response = response.get_return();
for (SyndicationService_Data syndicationService_Data :
synservice_response) {
System.out.println("Syndication Type: " +
syndicationService_Data.getType().getValue());
System.out.println("Publisher Id: " +
syndicationService_Data.getId());
}
} catch (CreateAccountFault fault) {
System.out.println("Due to axis issues, only AxisFault will ever
be thrown");
System.out.println("Therefore, this catch block is for
completeness only.");
} catch (org.apache.axis2.AxisFault fault) {
OMElement faultElement = fault.getDetail();
OMElement exElement = (OMElement) (faultElement.getChildElements
().next());
Iterator<?> i = exElement.getChildElements();
OMElement codeElement = (OMElement) i.next();
OMElement internalElement = (OMElement) i.next();
OMElement messageElement = (OMElement) i.next();
OMElement triggerElement = (OMElement) i.next();
OMElement triggerDetailsElement = (OMElement) i.next();
System.out.println("Code: " + codeElement.getText());
System.out.println("Internal: " + internalElement.getText());
System.out.println("Message: " + messageElement.getText());
System.out.println("Trigger: " + triggerElement.getText());
System.out.println("Trigger Detail: " +
triggerDetailsElement.getText());
} catch (java.rmi.RemoteException e) {
System.out.println("remote exception");
}
}
}

Cheers,
Wes
AdSense API
> > > > When i get the wsdl from the sandbox, the stubs are generated usinghttp://www.google.com/api/adsense/v3insteadoftheoldhttps://sandbox.google.com
> > > > url.
>
> > > > when i try to go towww.google.com/api/adsense/v3redirectsme(in
> > > > firefox) to  httpS://www.google.com/api/adsense/v3andthenshowsme a

Alejandro Vera

unread,
Feb 5, 2009, 2:06:35 PM2/5/09
to AdSense API Forum
The only glitch is that in the command line you wrote ./axis2-1.4.1/
bin/wsdl2java.sh -p com.google.api.adsense.v3.AccountService but in
order to work it must say

com.google.WWW.api.adsense.v3.AccountService

After that all worked as espected.. thanks for all the work and for
the example.. i think i could never get it done in my own..

now I'm going to work in reports.. thanks again!!!


On 3 feb, 22:16, adsenseapi-supportt...@google.com wrote:
> Alejandro,
>
> It looks like Axis2 v1.4's wsdl2java implementation automatically
> generates SOAP 1.2 bindings for the service; these appear to be
> slightly incompatible--at least, with respect to faults--with our
> service, so I suggest you use either the '-ap' or '-pn v3/$
> {SERVICENAME}SOAP11port_https' (where ${SERVICENAME} is similar to
> AccountService, etc.) flags to generate SOAP 1.1 bindings.  For
> reference, my command looks like this:
> ./axis2-1.4.1/bin/wsdl2java.sh -p
> com.google.api.adsense.v3.AccountService -ap -urihttps://sandbox.google.com/api/adsense/v3/AccountService?wsdl
>
> After generating stubs for the AccountService, I wrote a short
> (relatively speaking) java sample to call the CreateAccount method,
> which I've appended below.  I'm sure the formatting is going to get
> messed up, but I hope you can get the idea.  I'll write a few more and
> then get them up under our sample code section.
>
> // Copyright 2009 Google Inc. All Rights Reserved.
>
> package com.google.api.adsense.v3.SampleCode;
>
> import com.google.api.adsense.v3.AccountService.CreateAccountFault;
> import
> com.google.api.adsense.v3.AccountService.V3AccountServicev3AccountServiceSOAP11Port_httpsStub;
> import
> com.google.api.adsense.v3.AccountService.V3AccountServicev3AccountServiceSOAP11Port_httpsStub.SyndicationService_Data;
>
> import org.apache.axis2.client.ServiceClient;
> import org.apache.axiom.om.OMElement;
>
> import java.util.Iterator;
> import javax.xml.namespace.QName;
>
> /**
>  * Sample code for calling AdSense API v3's CreateAccount method.
>  *
>  * @author adsenseapi-supportt...@google.com (Wes Goodman)
> > > > > When i get the wsdl from the sandbox, the stubs are generated usinghttp://www.google.com/api/adsense/v3insteadoftheoldhttps://sandbox.go...
> > > > > url.
>
> > > > > when i try to go towww.google.com/api/adsense/v3redirectsme(in
> > > > > firefox) to  httpS://www.google.com/api/adsense/v3andthenshowsmea
> > > > > ssl certificade error
>
> > > > > (Error code: ssl_error_bad_cert_domain)
>
> > > > > Do you know what i am doing wrong??
>
> > > > > Thank wes
>
> > > > > On 30 ene, 09:17, Alejandro  Vera <alejandro.v...@gmail.com> wrote:
>
> > > > > > Thanks again wes...
>
> > > > > > I am reading the docs right now..
>
> > > > > > only that is strange that in the past there were examples for java
> > > > > > like "how to ask for a report" but no
>
> ...
>
> leer más »
Reply all
Reply to author
Forward
0 new messages