Friday, August 1, 2008

AdSense API v3 Migration Issues

This article provides solutions to common AdSense API v3 migration issues raised in the forum:

* Endpoints
* Namespace Declarations
* Enumerations
* Nillable Elements
* generateSearchBoxCode
* XML Samples

Endpoints

Changes to the back-end resulted in binding locations being written with IPs and port numbers. If your SOAP toolkit lets you override the endpoints, you should point to the following URL:

https://www.google.com/api/adsense/v3/service_name

If your toolkit does not let you override endpoints, you can download the WSDLs and replace all instances of http://10.130.140.30:8080/axis2/services with https://www.google.com/api/adsense (or the sandbox equivalent).
Namespace Declarations

AdSense API v3 requires the namespace declaration in the method-wrapper tag. The following XML snippet demonstrates how to declare namespace prefixes:


...


Enumerations

AdSense API v3 requires the use of enclosing tags around enumeration values (e.g. enum_value), even for sequences of length 1.


ContentAds


ContentAds


ContentAds
SearchAds

Nillable Elements

Empty elements, such as in generateAdCode, require the attribute xsi:nil="1". You must also add the namespace declaration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" to the method wrapper.


...

...


Note: xsl:nil="true" is not yet supported.
generateSearchBoxCode

To specify the empty string for encoding, do not use:




Use this form instead:




XML Samples

Here are some working XML samples for AdSense API v3.
createAccount




DEVELOPER_EMAIL
en_US
DEVELOPER_PASSWORD



CLIENT_EMAIL
Individual
tx-systems.com
en
en_US
true
ContentAds
http://code.google.com




associateAccount




DEVELOPER_EMAIL
en_US
DEVELOPER_PASSWORD



CLIENT_EMAIL
CLIENT_POSTAL_CODE

SITE_URL




generateAdCode




DEVELOPER_EMAIL
DEVELOPER_PASSWORD
CLIENT_ID



SYNDICATION_SERVICE_ID

#FFFFFF
#000000

#00FF00
#0000CC
#FF3300


728x90

False

DEFAULT