?
?
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
- Catch (apiexceptionApiex)
- {
- ???? var str = string. Empty;
- ? ??? foreach (ErrorType error in apiex.errors)
- ???? {
- ???????? if (Error.) Severitycode = = Severitycodetype.error)
- ???????? {
- ???????????? foreach (Errorparametertype Epara in error.) Errorparameters)
- ???????????? {
- ???????????????? str + = Epara.paramid + ":" + epara.value +"";
- ???????????????? if (Epara.paramid = = "SKU")
- ???????????????? {
- ???????????????????? Returns. Remove (returns. First (ZW = ZW). SKU = = Epara.value));
- ????????????????}
- ????????????}
- ???????????? str + = error. Longmessage + Environment.NewLine;
- ????????}
- ????}
- ?
- ???? //have the wrong
- ???? Notifyandlog (string. Format (respricecaptureandrevise.wrong_pricerevised, "", str),
- ???????? Loglevel.error, Accpriceinfo.selleraccount);
- }
?
If you use ACK to judge, there may be some data returned when the state is not success, but warning
- if (Apicall. Apiresponse.ack = = Ackcodetype.success | | Apicall. Apiresponse.ack = = ackcodetype.warning)
- {
- ??? //
- }
?
Pagination
- paginationtypepager = new paginationtype ();
- Pager. Entriesperpage = 100;
- Pager. Entriesperpagespecified = true;
- ?
- for (int page = 1; page <= totalpage; page++)
- {
- ???? Pager. pagenumber = page;
- ???? Pager. Pagenumberspecified = true;
- ?
- ???? if (Apicall. Apiresponse.ack = = Ackcodetype.success | | Apicall. Apiresponse.ack = = ackcodetype.warning)
- ???? {
- ???????? //Save Data
- ???????? Totalnum = (Apicall. Apiresponse.paginationresult = = null ? 0:apicall. Apiresponse. Paginationresult.totalnumberofentries);
- ??????? ? totalpage = (Apicall. Apiresponse.paginationresult = = null ? 0:apicall. ApiResponse.PaginationResult.TotalNumberOfPages);
- ?????}
- }
In Apiresponse. Paginationresult Totalnumberofentries and Totalnumberofpages get the total and the number of pages.
EBay. Net SDK API Practices