Jaweed Ali Qureshi

Subscribe to Jaweed Ali Qureshi: eMailAlertsEmail Alerts
Get Jaweed Ali Qureshi: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: Java EE Journal, XML Magazine

J2EE Journal: Article

WebSphere Commerce Integration with eBay:

Using the eBay SDK and Web Services

IBM WebSphere Commerce is a J2EE-based product which provides a platform for developers to write an integrated extensible solution that adds value in customer-centric online business. WebSphere Commerce allows developers to customize its functionality according to current business demands so that the integration of specialized business functionality like auctions, third party shipping rate & tax calculation within WebSphere Commerce is possible by using Web Services & XML. eBay is the world's online marketplace where community of individuals and merchants has equal opportunity to buy and sell new or used goods at fair prices

eBay provides online interface for their customer as well as offer SDK and API (Application Programming Interface) for tool developers to create specialized applications that satisfy business need and market demand of any B2C Stores.

The eBay Auction Management module within WebSphere Commerce Accelerator providesstreamlines multi-channel management, integrated listing, and checkout tools within a single interface for your online B2C store.

The core functions this module is offer:

  • Manage your eBay Listings.
  • Centralized Product Data for Online Store and eBay Listings.
  • Winning Bidders Checkout through your B2C Store.
  • Scheduled List and Relist Items on eBay.
  • Integrated Order Management and Inventory Tracking
  • Control listing checkout and shipping preferences.
  • Streamline order management by directing buyers to checkout through your web store or use eBay to collect payment.
Introduction
eBay is a world wide online auction service provider where you can trade together with large retailers without high overheads or start up costs and sale or purchase item/items of your choice at competitive price eBay provides online interfaces to sell and buy an item as well as API to interact with directly to the eBay databases. you can create your own application to communicate with the eBay databases by using the API such as to develop a java based application, eBay SDK for Java is available and you can download it at http://developer.ebay.com/java/sdk/ and documentation for using eBay SDK is available with in this

SDK. Structure of eBay Java SDK
eBay provides SDK both for Windows and Java Technology. SDK for Windows encapsulate the XML API and the SDK for Java is based on SOAP API. In this article we will discuss only Java SDK structure. eBay SDK for Java is organized into five libraries:

  • API Library represents invocations of a particular eBay service. Its include AddItem, VerifyAddItem, RelistItem, ReviceItem, EndItem, GetItem, GetCategories, GetFeedback etc.
  • Kernel Library is closest to the SOAP layer and supplies the basic underlying and supporting functionality for API call classes. Its include ApiCall, ApiContext and ApiCredential. ApiCall is the base class that defines the functionality common to all API call classes. ApiContext defines the API context under which an API call is made. ApiCredential provides the mean for authentication data for a caller requesting user.
  • Attribute Library it includes sample implementations of the data provider interfaces. Each of these classes downloads the data directly from eBay and caches it in memory.
  • Picture Service Library defines the functionality needed for an application to use item picture files hosted on the eBay Picture Service (EPS) server. These include the classes eBayPictureService and PictureInfo.
  • Helper Library the rest of the services required for completing the eBay cycle are available on Helper Library like Shipping Service, Payment services etc.
Functionality Supported by SDK
  • Listing an Items
  • Monitoring active items
  • Post-sales processing (end-of-auction / end-of-transaction)
  • Getting and posting feedback
  • Checking for category updates, get user information.
A model Seller Application should support the following activities:
  • List an item
  • Check Status
  • Process Sales
  • Relist Items
  • Feedback processing
eBay integration with WebSphere Commerce
We can also use the eBay API inside the WebSphere Commerce environment. Integration of eBay API in Commerce Accelerator allows communication directly with the eBay database. By using this API, you can manage all of your ebay listings form Websphere Commerce Accelerator and also list any product to ebat from your WCS store catalog . The following figure shows the integration of eBay API

in WebSphere Commerce. Example using eBay API for Java in WebSphere Commerce Environment Let's consider a scenario where a user wants to add an item from the wcs store to eBay using commerce accelerator as shown in Figure 1. A user request for add an item by clicking the "add Item" button available . Than he selects a product based on the selected category and than sets additional information related to item for auction as shown in Figure 2. Now the item is ready to send on eBay auction site that is accomplished by the code shown in Listing1. The code utilizes the benefits of web services with the help of eBaySDK to complete the task as add Item. Commerce Accelerator WebSphere Commerce SOAP WebSphere Views / Business Logic eBay SDK for java Web service's Interfaces eBay WebServices WCS - eBay Integration Architecture

For calling any API call you must need to provide all the connection information that you can get from eBay site by creating your own account .You can either obtain a free individual account that allows you to use the eBay API, or a commercial account. By individual account you can make up to 5,000 calls per day in the Sandbox (test) environment and up to 50 calls per day in the live eBay environment for free. You can create your individual free account by visiting http://developer.ebay.com/join and click the join button on this page. The code fragment at Listing 1, line #1 shows the creation of an ApiContext object, specify values for its properties, and assign the ApiContext object to the ApiContext property of the API call object. By specifying the values in ApiContext object we can:
- Direct the call to the appropriate eBay API server
- Pass requesting user authentication credentials to eBay
- Determine the language in which error messages are passed back to the application
- Add to the running count of API calls made using that ApiContext object
- Control the logging of API calls

An application can set up a single ApiContext object and reuse it for multiple API calls made using different API call objects (different API call classes or multiple instances of the same class). By reuse the ApiContext object we can track the number of call made and safe the process of specifying authentication credentials again and again. The code fragment at Listing 1, line #11 shows the creation of AddItemCall object, the API allows you to call or create different types of objects depends on the type of call you want to make. For example list of items that let you know about the status of your item on eBay auction such as sold item, unsold item, active item and pending item can be retrieve by GetItemCall. Figure 3 shows a list of item retrieved by GetItemCall. AddItemCall object allows you to add an item to eBay auction site and the addItem method in Listing1, line#12 that takes your item as an argument not only makes a call to add an item but also provides you information about fee charged by eBay for auction and the id that is assigned by eBay to your item.

Listing 1

// Create an ApiCallContext object for the call ApiContext
ApiContext apiContext = new ApiContext();
// Specify the authentication token for the requesting user ApiCredential
ApiCredential cred = apiContext.getApiCredential();
ApiAccount ac = cred.getApiAccount();
String soapServer = "https://api.sandbox.ebay.com/wsapi";
ac.setDeveloper(devId);
ac.setApplication(appId);
ac.setCertificate(crtId);
cred.seteBayToken(token);
// Specify the eBay SOAP server URL
apiContext.setApiServerUrl(soapServer);
apiContext.setRouting("default");
// Create the AddItemCall object
11. AddItemCall api = new AddItemCall(apiContext);
// Make the call and get the fee and ebay id for the item submited
12. FeesType fees = api.addItem(item);

This article showed us how we can interact with eBay by using eBaySDK for java within the environment of WebSphere commerce that provides developer the flexibility to work with the outside world of the WebSphere commerce.

More Stories By Jaweed Ali Qureshi

Jaweed Ali Qureshi Sr. Software Engineer at Royal Cyber Inc.

More Stories By Malik M. Sarfaraz

Malik M. Sarfaraz Software Engineer Royal Cyber Inc.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.