⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amazonsearchclient.java

📁 kSOAP2是一个SOAP web service客户端包。主要用于资源受限制的Java环境如Applets或J2ME应用程序。
💻 JAVA
字号:
package org.ksoap2.samples.amazon.search;import org.ksoap2.*;import org.ksoap2.samples.amazon.search.messages.*;import org.ksoap2.serialization.*;import org.ksoap2.transport.*;public class AmazonSearchClient {    private static final String NAMESPACE = "http://webservices.amazon.com/AWSECommerceService/2006-05-17";    private static final String AMAZON_WEBSERVICE_KEY = "";    public AmazonSearchClient() {        if (AMAZON_WEBSERVICE_KEY.length() == 0) {            System.out.println("Please substitute your own amazon webservice key before running this code.");        } else {            Request requestObject = new Request();            requestObject.author = "Whyte";            requestObject.searchIndex = "Books";            SoapObject request = new SoapObject(NAMESPACE, "ItemSearch");            request.addProperty("SubscriptionId", AMAZON_WEBSERVICE_KEY);            request.addProperty("Request", requestObject);            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);            envelope.setOutputSoapObject(request);            requestObject.register(envelope);            registerObjects(envelope);            HttpTransportSE httpTransportSE = new HttpTransportSE("http://soap.amazon.com/onca/soap?Service=AWSECommerceService");            httpTransportSE.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");            try {                httpTransportSE.call("http://soap.amazon.com", envelope);                BookItems response = (BookItems) envelope.getResponse();                System.out.println(response);            } catch (Exception e) {                e.printStackTrace();            }        }    }    private void registerObjects(SoapSerializationEnvelope envelope) {        new ItemSearchResponse().register(envelope);    }    public static void main(String[] args) {        new AmazonSearchClient();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -