EBay. Net SDK API Practices

Source: Internet
Author: User
Tags ack

?

?

1. Request Process Introduction

?

Provide SOA address: HTTPS://API.EBAY.COM/WSAPI

?

The code generated by the WSDL is in the WebService.cs file.

?

Apicall encapsulates all of the RPC, its core implementation in SendRequest, where there are two events, before the request, and after the request

Customsecurityheadertype encapsulates user authentication information

Soaphttpclientprotocolex inherits the SoapHttpClientProtocol, plus the Soaprequest,soapresponse attribute. The XML message used to generate the request and response.

?

Using Apilogmanager for logging

?

2. Practice

?

    • Non-string field, using " property specified" = True

Such as:

Pagination. Pagenumberspecified = true;

?

    • Capture Apiexception, traverse errors to refine errors

For example: In Reviseinventorystatus, adjusting four SKUs at once requires traversing the error results

  1. Catch (apiexceptionApiex)
  2. {
  3. ???? var str = string. Empty;
  4. ? ??? foreach (ErrorType error in apiex.errors)
  5. ???? {
  6. ???????? if (Error.) Severitycode = = Severitycodetype.error)
  7. ???????? {
  8. ???????????? foreach (Errorparametertype Epara in error.) Errorparameters)
  9. ???????????? {
  10. ???????????????? str + = Epara.paramid + ":" + epara.value +"";
  11. ???????????????? if (Epara.paramid = = "SKU")
  12. ???????????????? {
  13. ???????????????????? Returns. Remove (returns. First (ZW = ZW). SKU = = Epara.value));
  14. ????????????????}
  15. ????????????}
  16. ???????????? str + = error. Longmessage + Environment.NewLine;
  17. ????????}
  18. ????}
  19. ?
  20. ???? //have the wrong
  21. ???? Notifyandlog (string. Format (respricecaptureandrevise.wrong_pricerevised, "", str),
  22. ???????? Loglevel.error, Accpriceinfo.selleraccount);
  23. }

?

    • Using Apiresponse.ack

If you use ACK to judge, there may be some data returned when the state is not success, but warning

    1. if (Apicall. Apiresponse.ack = = Ackcodetype.success | | Apicall. Apiresponse.ack = = ackcodetype.warning)
    2. {
    3. ??? //
    4. }

?

    • Page out

Pagination

  1. paginationtypepager = new paginationtype ();
  2. Pager. Entriesperpage = 100;
  3. Pager. Entriesperpagespecified = true;
  4. ?
  5. for (int page = 1; page <= totalpage; page++)
  6. {
  7. ???? Pager. pagenumber = page;
  8. ???? Pager. Pagenumberspecified = true;
  9. ?
  10. ???? if (Apicall. Apiresponse.ack = = Ackcodetype.success | | Apicall. Apiresponse.ack = = ackcodetype.warning)
  11. ???? {
  12. ???????? //Save Data
  13. ???????? Totalnum = (Apicall. Apiresponse.paginationresult = = null ? 0:apicall. Apiresponse. Paginationresult.totalnumberofentries);
  14. ??????? ? totalpage = (Apicall. Apiresponse.paginationresult = = null ? 0:apicall. ApiResponse.PaginationResult.TotalNumberOfPages);
  15. ?????}
  16. }

In Apiresponse. Paginationresult Totalnumberofentries and Totalnumberofpages get the total and the number of pages.

EBay. Net SDK API Practices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.