Skip to main content
Published: May 05 2011, 3:33:00 AMUpdated: November 28 2020, 9:25:59 PM

How do I call the FindProducts call using JAX-WS ?

This sample uses wsimport tool that ships with JAX-WS to generate Java code stubs and demonstrates how to make Shopping API calls.

Detailed Description

Software Requirements:

Generate Java code stub using wsimport tool:

Once you have set up JAW-WS on your machine, go to the {JAX-WS install-dir}/bin directory where you will find the wsimport tool. Open command prompt, change the directory to {JAX-WS install-dir}/bin and enter the following command:

wsimport -extension

This will generate the required Java classes from the WSDL

Sample code for FindProducts call:

In the below code, replace "YOUR APP ID" with your actual AppID generated through the developer account.

/*  © 2011-2013 eBay Inc., All Rights Reserved */
/* Licensed under CDDL 1.0 - */


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import ebay.apis.eblbasecomponents.CatalogProductType;
import ebay.apis.eblbasecomponents.ProductIDCodeType;
import ebay.apis.eblbasecomponents.ProductIDType;

 @author rvenkitasubraman
 * This is based on the FindPopularSearchResults sample
public class FindPopularSearches {

    private static final String APPID = "YOUR APP ID";
    private static final String CALLNAME = "FindProducts";
    private static final String VERSION = "771";
    private static final String BASEURL = "";
    private static BindingProvider bp;

    public static void main(String[] args) {
        String endpointURL = BASEURL;

            ebay.apis.eblbasecomponents.Shopping service = new ebay.apis.eblbasecomponents.Shopping();
            ebay.apis.eblbasecomponents.ShoppingInterface port = service.getShopping();
            bp = (BindingProviderport;
            // bp = (BindingProvider) port;
            // Add the logging handler
            List<Handler> handlerList = bp.getBinding().getHandlerChain();
            if (handlerList == null) {
                handlerList = new ArrayList<Handler>();
            LoggingHandler loggingHandler = new LoggingHandler();
            // register the handerList

            Map<String,Object> requestProperties = bp.getRequestContext();
            Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
            requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
            // set reqired HTTP Headers :
            httpHeaders.put("X-EBAY-API-CALL-NAME", Collections.singletonList(CALLNAME));
            httpHeaders.put("X-EBAY-API-APP-ID", Collections.singletonList(APPID));
            httpHeaders.put("X-EBAY-API-VERSION", Collections.singletonList(VERSION));

            requestProperties.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
            // initialize WS operation arguments here
            ebay.apis.eblbasecomponents.FindProductsRequestType request = new ebay.apis.eblbasecomponents.FindProductsRequestType();
            // Using Keyword search
            // Setting the resultset size to 10
            // You can search based on categories too.
            // submit the request
            ebay.apis.eblbasecomponents.FindProductsResponseType response = port.findProducts(request);
            // process result here
            System.out.println(" EndpointURL : " + endpointURL);
            System.out.println("Status = " + response.getAck());

            List<CatalogProductType> resultList = response.getProduct();
            if (resultList != null) {
                for (CatalogProductType result : resultList) {
                  List<ProductIDType>productIds = result.getProductID();
                  String ePID = "";
                  for (ProductIDType productIDType : productIds) {
                  System.out.format("ProductID(ePID): %s, Details URL: %s", ePID,result.getDetailsURL());
        catch (Exception ex) {

You can find the code and generated stubs attached to this to get you started!

How well did this answer your question?
Answers others found helpful