Yahoo! Search Marketing

YSM Yahoo! Group Discussions

View All

YSM Blog Posts

Enjoy the Silence (While You Can)
Tue, 24 Nov 2009 19:15:31 +0000

Breaking News from Yahoo! News
Fri, 20 Nov 2009 00:47:21 +0000

You’re Invited…
Tue, 17 Nov 2009 20:03:16 +0000

Anti-Phishing Reminders
Mon, 16 Nov 2009 20:56:48 +0000

One Shining Moment
Thu, 12 Nov 2009 18:28:28 +0000

View All

Sample Code: Java Client Application

To access Enterprise Web Services (EWS) using the sample Java client application, follow these instructions.

Environment

To set up your Java environment, install the following packages according to the directions on their respective web sites:

We recommend that you use Java 1.5. We also recommend that you use Axis 1.4 to ensure that the sample client application compiles correctly.

Note: Contact your system administrator if you need help setting up your Java environment.

Source Code

For Java, the sample code includes API specific code and use cases. While API specific sample code helps you understand the usage of individual API, the use cases demonstrate a workflow or typical system usage.

Please refer to the Build and Run section below to know how to use these sample codes

Prerequisites

The Java sample source code below makes use of the following EWS utility files. These files abstract out the configuration and service management used in the sample source code.

Note : These files must be included in the classpath when executing the sample source code.

API Specific Sample Code

The following sample codes are available for EWS APIs :

Use Cases / Workflows

The following use cases are available:

Download All Source Files

You can download all the above sources and utility source files: .jar, .zip, .tar.gz, .tar.bz2.
You can download all the EWS Java Axis Stub classes and sources as well: .jar (classes only), .zip, .tar.gz, .tar.bz2.

Build and Run

To build and run the Java client application, follow the steps given below:

Quick Start

You can get started quickly by downloading the EWS sample code sources, required libraries, and Ant build file.

  1. Ensure you have Apache Ant 1.6.5 or higher in your PATH.
  2. Download the EWS API SDK archive: .zip, .tar.gz, .tar.bz2.
  3. Extract the SDK to your local directory.
  4. Modify the ewsconfig.properties file in the properties folder in the extracted directory. Make sure that you fill in the credentials and market information correctly.
  5. Compile the sample code using Ant:

    prompt> ant -f build.xml

  6. After compiling, you can run a specific sample code using the following command:

    prompt> ant -f build.xml -Dclass=<CLASS TO RUN> [-Dargs=<ARGUMENTS TO PASS TO CLASS>]

    For example:

    prompt> ant -f build.xml -Dclass=com.yahoo.sm.ws.client.AddAds -Dargs="123456"

Manual Do-It-Yourself

You can get the sample code up and running by manually getting the dependencies in place and compiling the sample code against them. Follow the steps listed below:

Sr. No. Description
Step 1a.

You need the Axis Java client stub classes to comiple and run the sample code.

You can download the pre-compiled stubs with sources: .jar (classes only), .zip, .tar.gz, .tar.bz2.

Alternately, you can generate the stubs on your own by following the steps below.

Download the WSDLs for these Marketing API services to your local directory:

  • LocationService
  • CampaignService
  • AdGroupService
  • AdService
  • KeywordService
  • ExcludedWordsService

You may want to download all the WSDLs if you plan to expand the sample client application to use more services or to execute the use cases.

Step 1b.

Skip this step if you have downloaded the stubs listed above.

Create the Axis client stub classes for all the WSDLs using Axis' wsdl2java with these arguments:

  • --NStoPkg http://marketing.ews.yahooapis.com/V5=com.yahoo.sm.ws.client
  • -o <dir you want to put the generated stubs>
  • -T 1.3
  • <location of WSDL file>
Step 2.

Download the sample data properties files and save them to your local directory. You can download

  • Sample data file for your market alone (sample_data_<YOUR MARKET>.properties) from here, or
  • Download all sample data files as an archive : .jar, .zip, .tar.gz, .tar.bz2
Step 3.

Download

Step 4.

Make sure that the following are in your classpath:

  • Java sample source files
  • Sample data property file/jar
  • EWS configuration property file
  • The Axis stub classes/jar
  • Axis jars
Step 5.

Modify the ewsconfig.properties file and add your acount details to the file :

  • USERNAME
  • PASSWORD
  • LICENSE
  • MASTER_ACCOUNT_ID
  • ACCOUNT_ID
  • MARKET
  • LOCALE

Step 6.

Compile Java sample source code (includeing helpers) and the generated stubs.


Step 7.

Run the sample code :

prompt> java <CLASS TO RUN>

For example :

prompt> java com.yahoo.sm.ws.client.AddAds



Known Issues

There are no known issues at this time.