私はAmazonのProduct Advertising APIを使って遊んでいます。 http://docs.amazonwebservices.com/AWSECommerceService/2011-08-01/GSG/この:私はこれのオフに取り組んできましたAmazon Product Advertising API signed request with JavaここJava/SOAPによるAmazon Product Advertising API
が私のコードです..私は、この使用してSOAPバインディングを生成:クラスパス上http://docs.amazonwebservices.com/AWSECommerceService/2011-08-01/GSG/YourDevelopmentEnvironment.html#Java
を、私は持っている:commons-codec.1.5.jar
import com.ECS.client.jax.AWSECommerceService;
import com.ECS.client.jax.AWSECommerceServicePortType;
import com.ECS.client.jax.Item;
import com.ECS.client.jax.ItemLookup;
import com.ECS.client.jax.ItemLookupRequest;
import com.ECS.client.jax.ItemLookupResponse;
import com.ECS.client.jax.ItemSearchResponse;
import com.ECS.client.jax.Items;
public class Client {
public static void main(String[] args) {
String secretKey = <my-secret-key>;
String awsKey = <my-aws-key>;
System.out.println("API Test started");
AWSECommerceService service = new AWSECommerceService();
service.setHandlerResolver(new AwsHandlerResolver(
secretKey)); // important
AWSECommerceServicePortType port = service.getAWSECommerceServicePort();
// Get the operation object:
com.ECS.client.jax.ItemSearchRequest itemRequest = new com.ECS.client.jax.ItemSearchRequest();
// Fill in the request object:
itemRequest.setSearchIndex("Books");
itemRequest.setKeywords("Star Wars");
// itemRequest.setVersion("2011-08-01");
com.ECS.client.jax.ItemSearch ItemElement = new com.ECS.client.jax.ItemSearch();
ItemElement.setAWSAccessKeyId(awsKey);
ItemElement.getRequest().add(itemRequest);
// Call the Web service operation and store the response
// in the response object:
com.ECS.client.jax.ItemSearchResponse response = port
.itemSearch(ItemElement);
String r = response.toString();
System.out.println("response: " + r);
for (Items itemList : response.getItems()) {
System.out.println(itemList);
for (Item item : itemList.getItem()) {
System.out.println(item);
}
}
System.out.println("API Test stopped");
}
}
ここで
は私が戻って何を得る..私はアマゾンで利用できるいくつかのスターウォーズの本は私のコンソールに出てダンプを参照することを望んでいたです: - /:
API Test started
response: [email protected]
[email protected]
API Test stopped
私は間違っています(2番目のforループの "item"は空であるため、何も出力されません)。これをトラブルシューティングするか、関連するエラー情報を取得するにはどうすればよいですか?
あなたがアマゾンからのXMLレスポンスをチェックするのtcpmonまたは類似を使用することができるかどうかはい、ご覧ください。その後、XMLで完全なエラーメッセージを見ることができます。 – davidfrancis