If you have any question left, please drop a note with the discussion link of this page.

API Version 2009-02-01 Java Client

From Wiki.zanox.com

Jump to: navigation, search

The following code and documentation targets the 2009-02-01 version.

The Java Application Client (jac) simplifies the usage of the zanox Web Services API by providing a set of classes and methods to integrate into your Java application.

Step 1: Download current Java API client
Step 2: Extract Java API client
Step 3: Try the example below

The example illustrates on how you can use the Java API client in a Java program

 
package com.zanox.api;
 
import com.zanox.api.namespace._2009_02_01.ProductItem;
import com.zanox.api.namespace._2009_02_01.ProductsResult;
import com.zanox.api.namespace._2009_02_01.Response;
 
public class ServiceTestTest {
 
    private static final String APPLICATION_KEY = ""; // insert here yout appId                                                                                         
 
    private static final String SHARED_KEY      = ""; // insert here your sharedKey
 
 
    public static void main(String[] args) {
        final ServiceTestTest serviceTest = new ServiceTestTest();
 
        ZanoxWSInterface soapClient = ZanoxWSFactory.getSoapWS2009_02_01();
        ZanoxWSInterface restClient = ZanoxWSFactory.getRestWS2009_02_01();
 
        serviceTest.test(soapClient, APPLICATION_KEY, SHARED_KEY);
        serviceTest.test(restClient, APPLICATION_KEY, SHARED_KEY);
    }
 
    private void test(ZanoxWSInterface zanoxWSInterface, String applicationKey, String sharedKey) {
 
        zanoxWSInterface.setApiKey(applicationKey);
        zanoxWSInterface.setSharedKey(sharedKey);
 
        try {
            Response searchProducts = zanoxWSInterface.searchProducts("dvd", null, "de", 0, null,
                null, null, 0, 0, 20);
            ProductsResult productsResult = searchProducts.getProductsResult();
            for (ProductItem productItem : productsResult.getProductItem()) {
                System.out.println("Name: " + productItem.getName()
                    + "Manufacturer: "
                    + productItem.getManufacturer());
            }
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }
}
 
Personal tools