Skip to main content
Published: October 14 2009, 6:11:00 AMUpdated: August 11 2022, 9:21:44 AM

How can I generate Java code stubs against Finding API WSDL using wsimport tool and make Finding API calls?


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

Detailed Description

Software Requirements:

        Java Downloads ( (wsimport tool is available from jdk5 onwards))

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 and you should see all the classes in the ./com/ebay/marketplace/search/v1/services directory.

Sample Java class:

© 2009-2013 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 -

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



public class FindingSample
     public static void main(String[] args)
        String strBaseURL = "";
        FindingService service = new FindingService();
        FindingServicePortType port     = service.getFindingServiceSOAP12PortHttp();
        BindingProvider bp = (BindingProvider) port;
        Map<String, Object> requestProperties = bp.getRequestContext(); 
        Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>(); 
        //Set the headers
        httpHeaders.put("X-EBAY-SOA-MESSAGE-PROTOCOL", Collections.singletonList("SOAP12"));
        httpHeaders.put("X-EBAY-SOA-OPERATION-NAME", Collections.singletonList("findItemsAdvanced"));  
        //Edit the following line to insert your AppID to set the X-EBAY-SOA-SECURITY-APPNAME correctly
        httpHeaders.put("X-EBAY-SOA-SECURITY-APPNAME", Collections.singletonList("YOUR_APP_ID_HERE"));
        requestProperties.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
        requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, strBaseURL);

        FindItemsAdvancedRequest req = new FindItemsAdvancedRequest();
        List<OutputSelectorType> opSelector = req.getOutputSelector();
        ItemFilter objFilter1 = new ItemFilter();
        ItemFilter objFilter2 = new ItemFilter();

        ItemFilter objFilter3 = new ItemFilter();

       // set the time filters
        ItemFilter endtimefromFilter = new ItemFilter();
        List<String> endtimefrom = endtimefromFilter.getValue();
        ItemFilter endtimetoFilter = new ItemFilter();
        List<String> endtimeto = endtimetoFilter.getValue();

        List<ItemFilter> itemFilter = req.getItemFilter();
        List<String> catID = req.getCategoryId();

        req.setKeywords("Harry Potter");

        FindItemsAdvancedResponse res = port.findItemsAdvanced(req);
        System.out.println("Search Count: " + res.getSearchResult().getCount());

Set CLASSPATH and run the code sample:

Please ensure that the following are included in your classpath before you run the above Java code.

  • Include the jars in the {JAX-WS install-dir}/lib directory
  • Include the Java stub classes generated by the wsimport tool as instructed in the sample earlier.

Now you can compile and run the sample.


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