Hi everyone. I need to make search in ebay. I found a finding.jar and try to do. But I have some doubt with use it.
I need to make search by some params. I did some simple code that illustrate my problems
[code]
package test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.ebay.services.client.ClientConfig;
import com.ebay.services.client.FindingServiceClientFactory;
import com.ebay.services.finding.*;
/**
* A sample to show eBay Finding service call using the simplified interface
* provided by the findingKit.
*
* @author boyang
*
*/
class FindByKey extends FindItemsByKeywordsRequest {
public FindByKey() {
this.itemFilter = new ArrayList<ItemFilter>();
}
public void add(ItemFilter filter) {
this.itemFilter.add(filter);
}
}
public class FindItem {
public static ItemFilter buildFulter(ItemFilterType type, String value) {
ItemFilter filter = new ItemFilter();
filter.setName(type);
filter.setParamValue(value);
return filter;
}
public static void main(String[] args) {
try {
// initialize service end-point configuration
ClientConfig config = new ClientConfig();
config.setEndPointAddress("http://svcs.sandbox.ebay.com/services/search/FindingService/v1");
config.setApplicationId("AppID");
//create a service client
FindingServicePortType serviceClient = FindingServiceClientFactory.getServiceClient(config);
FindByKey request = new FindByKey();
request.add(buildFulter(ItemFilterType.CURRENCY, "USD"));
request.add(buildFulter(ItemFilterType.MIN_BIDS, "0.1"));
request.add(buildFulter(ItemFilterType.MAX_BIDS, "10.0"));
//set request parameters
request.setKeywords("Harry Potter");
PaginationInput pi = new PaginationInput();
pi.setEntriesPerPage(10);
request.setPaginationInput(pi);
//call service
FindItemsByKeywordsResponse result = serviceClient.findItemsByKeywords(request);
System.out.println("Ack = "+result.getAck());
System.out.println("Find " + result.getSearchResult().getCount() + " items." );
List<SearchItem> items = result.getSearchResult().getItem();
for(SearchItem item : items) {
System.out.println("Items : " + item.getTitle());
Amount amount = item.getListingInfo().getBuyItNowPrice();
if (amount != null) {
System.out.println("Price : " + amount.getValue() + " " + amount.getCurrencyId());
}
}
} catch (Exception ex) {
// handle exception if any
ex.printStackTrace();
}
}
}
[code]
But when I run it I have exceptions.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<findItemsByKeywordsResponse xmlns="http://www.ebay.com/marketplace/search/v1/services">
<ack>Failure</ack>
<errorMessage>
<error>
<errorId>46</errorId>
<domain>Marketplace</domain>
<severity>Error</severity>
<category>Request</category>
<message>Value is required for item filter, CURRENCY.</message>
<subdomain>Search</subdomain>
<parameter>CURRENCY</parameter>
</error>
</errorMessage>
<version>1.11.0</version>
<timestamp>2011-11-03T08:23:17.373Z</timestamp>
</findItemsByKeywordsResponse>
</soapenv:Body>
</soapenv:Envelope>
Can you help me what I do wrong?
Thanks.