c#ebay api,适用于W7,但不适用于xp

时间:2010-09-11 18:11:50

标签: c# ebay

我开发了一个使用ebay的“finditemsAdvanced”api调用的应用程序。 它在Windows 7上运行没有问题但是当我在xp机器上尝试它时,该函数返回null !!!!我尝试在xp上调试它,使用vs2010和vs 2008但没什么!!!!

这里是搜索类:

 public SearchResult Search(Job searchedjob)
    {
        try
        {
            EbayFind service = new EbayFind();
            service.Url = "http://svcs.ebay.com/services/search/FindingService/v1";


            FindItemsAdvancedRequest findrequest = new FindItemsAdvancedRequest();

            ItemFilter[] filtro = new ItemFilter[1];
            int filter = 0;

            //Tempo rimanente
            filtro[filter] = new ItemFilter();
            filtro[filter].name = ItemFilterType.EndTimeTo;
            filtro[filter].value = new string[] { searchedjob.TimeLeft.ToString("yyyy-MM-ddTHH:mm:ss.000Z") };
            filter++;


            findrequest.keywords = "canon";
            findrequest.itemFilter = filtro;
            findrequest.descriptionSearch = false;

            // Setting the pagination
            PaginationInput pagination = new PaginationInput();
            pagination.entriesPerPageSpecified = true;
            pagination.entriesPerPage = 25;
            pagination.pageNumberSpecified = true;
            pagination.pageNumber = 1;
            findrequest.paginationInput = pagination;

            findrequest.paginationInput = pagination;

            // Creating an object to the BestMatchService class

            FindItemsAdvancedResponse resp = service.findItemsAdvanced(findrequest);
            SearchResult res = resp.searchResult;

            return res;
        }

这里是ebay电话:

 class EbayFind : FindingService
{
    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {

        try
        {

            HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
            request.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "myappid");
            request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsAdvanced");
            request.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "FindingService");
            request.Headers.Add("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP11");
            request.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
            request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
            return request;

        }

        catch (Exception ex)
        {
            throw ex;
        }

    }
}

}

此代码适用于w7机器,我不明白为什么“res”在xp上始终为null! 安装的网络框架是3.5和4.0,我认为这不是一个框架问题。 任何想法??

谢谢!

1 个答案:

答案 0 :(得分:0)

在黑暗中刺伤 - Windows防火墙。

尝试在调试时在控制面板中禁用它。如果它有所不同,请配置一个例外以允许来自您的应用程序的api调用。