Find the answer to your question
Advanced Search Product -Select Product- Trading API Shopping API Merchandising API Large Merchant Services Client Alerts API Feedback API Open eBay Apps Finding API Product Services Sandbox Others MIP Media API Notification API Identity API Charity API Taxonomy API Catalog API Recommendation API Compliance API Logistics API Finances API(Alpha) Negotiation API Listing API Sell Feed API Marketing Ads API Account API Inventory API Fulfillment API Marketing Promotion API Analytics API Metadata API Offer API Marketplace Insights API Deal API Marketing API Feed API Browse API Order API Analytics API Cancellation API Case Management API Inquiry API Return API
Category -Select- Getting Started Sample Code Troubleshooting HowTo's / Best Practices No Value
Language -Select- C# Flex Java JavaScript PHP VB.NET VB6
Format -Select- All XML SOAP JSON Name Value N/A
SDK -Select- .NET Java JavaScript Flax/Flash Mobile - iOS None
Sort by Default Summary New Description Date Updated
Sort order Descending Ascending
Search
Published: May 05 2011, 3:33:00 AM Updated: 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 http://developer.ebay.com/webservices/latest/ShoppingService.wsdl
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 - http://opensource.org/licenses/cddl1.php */
package com.ebay.test.shopping;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.MessageContext;
import ebay.apis.eblbasecomponents.CatalogProductType;
import ebay.apis.eblbasecomponents.ProductIDCodeType;
import ebay.apis.eblbasecomponents.ProductIDType;
import javax.xml.ws.handler.Handler;
/**
*
* @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 = "http://open.api.ebay.com/shopping?" ;
private static BindingProvider bp;
public static void main ( String [] args ) {
String endpointURL = BASEURL;
try {
ebay.apis.eblbasecomponents.Shopping service = new ebay.apis.eblbasecomponents.Shopping () ;
ebay.apis.eblbasecomponents.ShoppingInterface port = service.getShopping () ;
bp = ( BindingProvider ) port;
// bp = (BindingProvider) port;
bp.getRequestContext () .
put ( BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
endpointURL ) ;
// Add the logging handler
List<Handler> handlerList = bp.getBinding () .getHandlerChain () ;
if ( handlerList == null ) {
handlerList = new ArrayList<Handler> () ;
}
LoggingHandler loggingHandler = new LoggingHandler () ;
handlerList.add ( loggingHandler ) ;
// register the handerList
bp.getBinding () .setHandlerChain ( handlerList ) ;
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 :
// http://developer.ebay.com/DevZone/shopping/docs/Concepts/ShoppingAPI_FormatOverview.html#StandardURLParameters
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
request.setQueryKeywords ( "iPad" ) ;
// Setting the resultset size to 10
request.setMaxEntries ( 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 ) {
if ( productIDType.getType () .equals ( ProductIDCodeType.REFERENCE )){
ePID=productIDType.getValue () ;
}
}
System.out.format ( "ProductID(ePID): %s, Details URL: %s" , ePID,result.getDetailsURL ()) ;
System.out.println () ;
}
}
} catch ( Exception ex ) {
ex.printStackTrace ( System.err ) ;
}
}
}
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