将eBay搜索从美国更改为英国

时间:2014-05-13 12:55:08

标签: android soap-client ebay

我正在尝试更改我的易趣Android应用搜索的搜索网站。目前,它搜索美国网站,但我希望它搜索英国网站。

这是我的discoverServiceClient课程,我尝试使用国家/地区代码3(英国,source)搜索英国网站。

据我所知,我已将我的代码设置为搜索英国网站,但它似乎仍在搜索美国。

任何帮助都将不胜感激,谢谢。

public class FindingServiceClient {


// production
public static String eBayFindingServiceURLString = "http://svcs.ebay.com/services/search/FindingService/v1";
// sandbox
//public static String eBayFindingServiceURLString = "https://svcs.sandbox.ebay.com/services/search/FindingService/v1";
public static String eBayAppId = "ebay_app_id";

private static volatile FindingServicePortType_SOAPClient client = null;


public static String targetSiteid = "3";



public static FindingServicePortType_SOAPClient getSharedClient() {
    if (client == null) {
        synchronized(FindingServiceClient.class) {
            if (client == null) {
                client = new FindingServicePortType_SOAPClient();
                client.setEndpointUrl(eBayFindingServiceURLString);
                client.setSoapVersion(SOAPVersion.SOAP12); // ebay finding service supports SOAP 1.2
                client.setContentType("application/soap+xml");
                client.getAsyncHttpClient().addHeader("X-EBAY-API-SITE-ID", targetSiteid);
                client.getAsyncHttpClient().addHeader("Accept", "application/soap+xml");
                client.getAsyncHttpClient().addHeader("X-EBAY-SOA-SECURITY-APPNAME", eBayAppId);
                client.getAsyncHttpClient().addHeader("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP12");
                client.getAsyncHttpClient().addHeader("X-EBAY-SOA-REQUEST-DATA-FORMAT", "SOAP");

            }
        }
    }

    return client;
}

}

1 个答案:

答案 0 :(得分:1)

搜索的站点在HTTP标头 X-EBAY-SOA-GLOBAL-ID 中指定。此标头的值不是唯一的整数,例如3 ,而是唯一的字符串,,例如EBAY-US 。要搜索英国网站,您需要对代码进行以下两项更改,并删除对 X-EBAY-API-SITE-ID 的任何引用。

public static String targetSiteid = "EBAY-GB";

client.getAsyncHttpClient().addHeader("X-EBAY-SOA-GLOBAL-ID", targetSiteid);

易趣文档提供了complete list of HTTP headerstable of site IDs mapped to global IDs