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