For full functionality of this site it is necessary to enable JavaScript.
Here are the instructions how to enable JavaScript in your web browser.

Knowledge base

Find the answer to your question

Advanced Search PView

Search terms
Search Type
Product
Category
Language
Format
SDK
Sort by
Direction

LMS: Making a File Transfer (FT) call ( .NET sample )

  • Answer ID 1336
  • Published 12/10/2008 09:53 AM
  • Updated 10/20/2013 06:41 AM
  • Permalink https://ebaydts.com/eBayKBDetails?KBid=1336

HowTo make File Transfer (FT) call? ( .NET sample )


Application Description

The attached program is a console application that allows the user to make a FT uploadFile call in the Sandbox environment. Response details (success or failure) are displayed on the console. The application has been written in C# using the Visual Studio 2005 environment.

The application expects the parameters required for the uploadFile call (BDX jobID, BDX fileRefID, name of file to upload, user's sandbox token) to be present in the app.config file.

Pre-requisites: A Bulk Data Exchange(BDX) job has been created using the BDX createUploadJob call.

Notes: The jobID and fileReferenceId returned by the BDX call are required to be supplied to the UploadFile call.

Consuming File Transfer Web Service

Visual Studio .NET 2005 provides the capability to create class files that contain the proxy code to access the web services. The generated class is used to instantiate objects for communicating with the Web services.

1. Use the ServiceModel Metadata Utility Tool (svcutil.exe) to generate a configuration file and a code library to interface to our service. Two files will be generated - FileTransferService.cs and app.config. The utility can be found at the Windows SDK installation location, specifically, C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin

svcutil.exe https://storage.sandbox.ebay.com/FileTransferService?wsdl /config:app.config

2. Open Visual Studio 2005 and create a new solution that is a C# console application. Add the files generated in the step above to the project.

3. Edit the app.config file to contain

      <appSettings>
          <add key="jobID" value="BDX JobID"></add>
          <add key="fileRefID" value="BDX FileRefID"></add>
          <add key="fileName" value="C:\\AddFPItem.gz"></add>
          <add key="SandboxToken" value="YourSandboxToken"></add>
     </appSettings>

3. Make sure that the endpoint address in the app.config file is https://storage.sandbox.ebay.com/FileTransferService. Also ensure that the tag underneath the custom binding definition is <httpsTransport> instead of <httpTransport> .

4. Comment out the anyField field and the associated property in the BaseServiceResponse class in the FileTransferService.cs file.

5. Add a reference to System.ServiceModel and System.ServiceModel.Channels

6. The project is now ready for making the FT calls available.

Below is a code snippet that shows how to make a call to the uploadFile function. Download the sample application for details about the code.

 

FileTransferServicePortClient client = new FileTransferServicePortClient("FileTransferServiceSOAP");

using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))

{

HttpRequestMessageProperty httpRequest = new HttpRequestMessageProperty();

OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);

//Add the request headers

httpRequest.Headers.Add("X-EBAY-SOA-SECURITY-TOKEN", YourSecurityToken);

httpRequest.Headers.Add("X-EBAY-SOA-SERVICE-NAME", FileTransferService");

httpRequest.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");

httpRequest.Headers.Add("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP12");

httpRequest.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "uploadFile");

//Create upload file request

UploadFileRequest uploadReq = new UploadFileRequest();

uploadReq.fileAttachment = new FileAttachment();

FileStream fs = File.OpenRead(fileName);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);

uploadReq.fileAttachment.Data = data;
uploadReq.fileAttachment.SizeSpecified = true;
uploadReq.fileAttachment.Size = fs.Length;

uploadReq.fileReferenceId = fileRefId;

uploadReq.taskReferenceId = jobID;

uploadReq.fileFormat = "gzip";

//Make the uploadFile call and return the response

UploadFileResponse uploadResponse = client.uploadFile(uploadReq);

// Examine the response to determine success/failure

...

}

Additional Resources

Making an API call

FT call reference

 

File Attachments

How well did this answer your question?

Answers others found helpful

Print Email This Page Delicious Digg Facebook Reddit StumbleUpon Twitter