2016-06-05 14 views
1

Der Versuch, alle Kategorien von Ebay zu bekommen, um in die Datenbank zu schieben. Ich habe versucht, den Timeout-Wert des zugrunde liegenden API-Kontextes zu erhöhen, aber ich bekomme immer noch eine Zeitüberschreitung nach etwa zwei Minuten - was muss ich noch tun?eBay API - getCategories Zeitüberschreitung

 var c = new eBay.Service.Call.GetCategoriesCall(this.apiContext); 
     c.CategorySiteID = ((int)siteId).ToString(); // siteId is an eBay SiteCode enum value 
     var version = c.GetCategoriesVersion(); 
     c.DetailLevelList = new DetailLevelCodeTypeCollection(); 
     c.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); 
     c.ViewAllNodes = !onlyLeafCategories; 
     c.Timeout = 1000*60*20; 
     c.GetCategories(); // this causes a connection closed/timeout 

Antwort

0

diesen Code versuchen, es funktioniert für mich:

// get all categories from eBay 
        ApiContext context = GetApiContext(); 

        GetCategoriesCall apiCall = new GetCategoriesCall(context) 
        { 
         EnableCompression = true, 
         ViewAllNodes = true 

        }; 
        apiCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); 
        apiCall.GetCategories(); 

    public static ApiContext GetApiContext() 
    { 
     //apiContext is a singleton, 
     //to avoid duplicate configuration reading 
     if (apiContext != null) 
     { 
      return apiContext; 
     } 
     else 
     { 
      apiContext = new ApiContext(); 

      //set Api Server Url 
      apiContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; 

      //set Api Token to access eBay Api Server 
      ApiCredential apiCredential = new ApiCredential(); 
      apiCredential.eBayToken ="YOUR_TOKEN"; 
      apiContext.ApiCredential = apiCredential; 
      //set eBay Site target to US 
      apiContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; 
      return apiContext; 
     } 
    } 
Verwandte Themen