import import import import import import import import import
awsClient2.AWSECommerceService; awsClient2.AWSECommerceServicePortType; awsClient2.ItemSearchRequest; awsClient2.ItemSearchResponse; awsClient2.ItemSearch; awsClient2.Items; awsClient2.Item; awsClient2.AwsHandlerResolver; java.util.List;
class AmazonClientU { // U is for Unwrapped style public static void main(String[] args) { // Usage if (args.length < 2) { System.err.println("Usage: java AmazonClientW
<secret key>"); return; } final String access_key = args[0]; final String secret_key = args[1]; // Create service and get portType reference. AWSECommerceService service = new AWSECommerceService(); service.setHandlerResolver(new AwsHandlerResolver(secret_key)); AWSECommerceServicePortType port = service.getAWSECommerceServicePort(); // Create request. ItemSearchRequest request = new ItemSearchRequest(); // Add details to request. request.setSearchIndex("Books"); request.setKeywords("quantum gravity"); ItemSearch item_search = new ItemSearch(); item_search.setAWSAccessKeyId(access_key); item_search.getRequest().add(request); // Invoke service operation and get response. ItemSearchResponse response = port.itemSearch(item_search);
} }
List item_list = response.getItems(); for (Items next : item_list) for (Item item : next.getItem()) System.out.println(item.getItemAttributes().getTitle());