I am just learning how to integrate with the eBay API and I am struggling to get things working.
So far I can list a single fixed price item using the standard trading API, but I need to be able to bulk upload items so I am investigating the Large Merchant Service API.
Currently my workflow is as follows:
- Find outstanding jobs and abort them
- Create a new
CreateUploadJobRequest
- Create a new
UploadFileRequest
- Create a new
StartUploadJobRequest
- Create a new
GetJobStatusRequest
- Create a new
DownloadFileRequest
Everything is going fine (I think) up until step 6. The request fails with a ProtocolException
.
Up until that point I have been getting fileReferenceId
‘s, jobId
‘s and successful responses. The code I am using to try and do this (nasty looking as it is) is:
httpRequest.Headers.Remove("X-EBAY-SOA-SERVICE-NAME");
httpRequest.Headers.Remove("X-EBAY-SOA-OPERATION-NAME");
httpRequest.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "FileTransferService");
httpRequest.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "downloadFile");
if (jobStatResp != null)
{
var ftclient2 = new FileTransferServicePortClient("FileTransferServiceSOAP");
using (OperationContextScope scope2 = new OperationContextScope(ftclient2.InnerChannel))
{
OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);
DownloadFileRequest downloadReq = new DownloadFileRequest();
downloadReq.fileReferenceId = jobStatResp.jobProfile[0].fileReferenceId;
downloadReq.taskReferenceId = jobStatResp.jobProfile[0].jobId;
DownloadFileResponse downloadResponse = ftclient2.downloadFile(downloadReq);
FileAttachment attachment = downloadResponse.fileAttachment;
FileStream fs = File.Create("response"+Guid.NewGuid());
BinaryWriter writer = new BinaryWriter(fs);
writer.Write(attachment.Data);
writer.Close();
fs.Close();
}
}
I’ve gone through in debug mode and I am getting a fileReferenceID
and jobID
.
One thought that comes to mind is that there is a problem with the uploaded xml, the only other thing I can think of is that there is an issue with some of my headers, but I can’t see what the issue is.
Ideally I could do with help with the following:
- Best ways of debugging this and getting as much info from the service as possible
- Any thoughts on what might be going wrong
Thanks in advance, and please let me know if there is additional information required.
I have now managed to identify what the issue is so I’ll post the solution here for others who might struggle with this.
Within the app.config there needs to be the following attached to the FileTransferService
endpoint you have configured
<mtomMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</mtomMessageEncoding>
Thanks
2
Answers
This is a full working program
https://ebaydts.com/eBayKBDetails?KBid=1338
There is so much code to understand e call LMS services.
To execute requests such as Revise-Add-Relist-End FixedPriceItem via LMS you have to create an xml like this
You can create the ItemType XML using eBay SDK .NET and serializing the ItemType class.
Make sure to add xmlns=”urn:ebay:apis:eBLBaseComponents” where needed otherwise the parser at eBay will not work.
Zip it with CSharpZipLib and send via uploadEndToEnd method, get the response unzip the response file and parse the response xml.
I have the same issue to get a fails with a ProtocolException in the step 6 request. I tried kipper_t’s solution to add mtomMessageEncoding in app.config, however still got the same fail message.
Finally only the solution below works. Use this function to replace step 6, and the file download success:
https://ebay.custhelp.com/app/answers/detail/a_id/1567/~/downloadfile-sample-(xml)-in-c%23