文档中心 > Dropshipping(已废弃)

.NET SDK Tutorials

更新时间:2020/01/10 访问次数:10106

Environmental Dependency

  • .NET Framework 2.0 and later versions (Windows Phone platform not supported)

Usage Example

Obtain the current system time:

ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
TimeGetRequest req = new TimeGetRequest();
TimeGetResponse rsp = client.Execute(req);
Console.WriteLine(rsp.Body);

Obtain the online logistics information:

String url = new String("http://gw.api.taobao.com/router/rest");
ITopClient client = new DefaultTopClient(url, appkey, secret);
AliexpressLogisticsRedefiningListlogisticsserviceRequest req = new AliexpressLogisticsRedefiningListlogisticsserviceRequest();
AliexpressLogisticsRedefiningListlogisticsserviceResponse rsp = client.Execute(req, sessionKey);
Console.WriteLine(rsp.Body);

Service URL

The following table lists API service URLs.

Environment HTTP Request URL HTTPS Request URL
Formal environment http://gw.api.taobao.com/router/rest https://eco.taobao.com/router/rest
Overseas formal environment http://api.taobao.com/router/rest https://api.taobao.com/router/rest

Advanced Features

  • Disable the interpretation of response character strings (where the object of XxxResponse is null):
DefaultTopClient.SetDisableParser(true)
  • Use the simplified JSON return format and remove redundant JSON nodes:
DefaultTopClient.SetUseSimplifyJson(true)
  • Disable API invocation logging:
DefaultTopClient.SetDisableTrace(true)
  • Ignore the HTTPS certificate check (It is recommended that the check be enabled only in the test environment.):
DefaultTopClient.SetIgnoreSSLCheck(true)
  • Disable GZIP compression for the response (It is strongly recommended that developers do not disable GZIP compression as it can significantly reduce network transmission.):
DefaultTopClient.SetUseGzipEncoding(false)
  • Set HTTP connection and read timeout intervals (Increase such timeout intervals appropriately under poor network conditions.):
//Default timeout interval for a response to an HTTP request: 20s
DefaultTopClient.SetTimeout(20000L)
//Default timeout interval for HTTP data read completion: 60s
DefaultTopClient.SetReadWriteTimeout(60000L)
  • Modify the storage path of logging:
DefaultTopLogger.FilePath = "c:/tmp/topsdk.log";
  • Enable an automatic retry for API invocation errors (Generally, a retry can be successful for ISP errors.):
AutoRetryTopClient client = new AutoRetryTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
client.SetMaxRetryCount(3);
client.SetRetryWaitTime(100L);
TimeGetRequest request = new TimeGetRequest();
TimeGetResponse response = client.Execute(request);
if (!response.IsError) {
         Console.WriteLine(response.Body);
}
  • Set shortest-path routing for API invocation (that is, invoke an API from the TOP equipment room nearest to the location where a request for API invocation is initiated):
ClusterTopClient client = new ClusterTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
TimeGetRequest request = new TimeGetRequest();
TimeGetResponse response = client.Execute(request);
Console.WriteLine(response.Body);

Important Notes

  • As the implementation class of ITopClient is thread-safe, there is no need to create a new ITopClient implementation class for each request for API invocation.
  • When an instance of the ITopClient implementation class is created, format is set to json. Compared to the XML format, the JSON format can reduce the volume of data transmission and improve the efficiency of requests for API invocation.

FAQ

关于此文档暂时还没有FAQ
返回
顶部