How to implement Google Adwords Soap Call using pure java

In this example you will see step-by-step instructions of how to create a java program without frameworks, using pure Java to extract data from your campaign. I assume that you have a campaign configured in your Google Adwords account. I recommend, before you read this paper, to take a look at the following link:

It’s about how the Adwords Api flow and how it was implemented.

To program Adwords call follow the step-by-step below.

1.- Proxy Config:

Java Proxy Config
First, if you need, I configure the proxy in pure java. You need to use System.setProperty to set the follow properties: https.proxyHost, https.proxyPort, http.proxyUser, http.proxyPassword, jsse.enableSNIExtension.

2.- Authorization:

In this step, I get authorization using the following entities: client_id, client_secret, refresh_token, grant_type (building post parameters).

3.- Build Adwords Query:

Then I set up the query that I will submit from Google Adwords.

4.- Executing query:

In this step we set information as below in the Http Header. One of the most important information is the authorization token refresh in step 2. Beyond the http header data, we need to configure the SOAP envelope, Body and Header. In the Header (RequestHeader) I set the clientCustomerId, developerToken and userAgent. The Body part must be configured depending on which query you want to run, in this case I user the CampaignServiceSoapBinding address location, operation get.


Below the complete Code:

I hope I have helped you.