The steps involved to create the webservice client for ebay shopping apis are as follows:
1- Create Standalone Java Project for example ShoppingAPIJavaClient as project name.
2-Include JAX-WS 2.1 java library
3-Create eBay Shopping Web Service Client(through wizard given under eclipse).
Make sure that you are giving ebay shopping apis wsdl as below:
http://developer.ebay.com/webservices/latest/ShoppingService.wsdl.
After completion of 3rd step you will see a package created on your project like eBLBaseComponents.apis.ebay which will have all the apis that will be used by webservice client.
6-Get the app_id from developer center of ebay.
5-Now create simple java client that will access the ebay shopping apis:
public class EbayClient {
private static final String APPID = "YOUR_APP_ID";//this you can get after developer center registration
private static final String CALLNAME = "FindItems";
private static final String VERSION = "711";
private static final String BASEURL="http://open.api.ebay.com/shopping?";
private static BindingProvider bp;
public static void main(String[] args) {
String endpointURL = BASEURL+"callname=" + CALLNAME+"&version="+VERSION+"&appid=" + APPID;
try { // Call Web Service Operation
eBLBaseComponents.apis.ebay.Shopping service = (Shopping) new ShoppingLocator();
System.out.println ( " EndpointURL2 : " + endpointURL);
eBLBaseComponents.apis.ebay.ShoppingInterface port = service.getShopping(new java.net.URL(endpointURL));
// initialize WS operation arguments here
eBLBaseComponents.apis.ebay.FindItemsRequestType findItemsRequest = new eBLBaseComponents.apis.ebay.FindItemsRequestType();
findItemsRequest.setQueryKeywords("iphone");
// process result here
eBLBaseComponents.apis.ebay.FindItemsResponseType result = port.findItems(findItemsRequest);
System.out.println ( " EndpointURL : " + endpointURL);
System.out.println("Status = "+result.getAck());
System.out.println("Number of total Items= "+result.getTotalItems());
System.out.println("Search Result URL = "+result.getItemSearchURL());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
This will give you the CLI output like:
EndpointURL2 : http://open.api.ebay.com/shopping?callname=FindItems&version=711&appid="YOUR_APP_ID"
EndpointURL : http://open.api.ebay.com/shopping?callname=FindItems&version=711&appid="YOUR_APP_ID"
Status = Success
Number of total Items= 419342
Search Result URL = http://search.ebay.com/ws/search/SaleSearch?DemandData=1&fsop=32&satitle=iphone
No comments:
Post a Comment