Home
Find the answer to your question
HowTo make Bulk Data Exchange (BDX) call? ( .NET sample )
Application Description
The attached program is a console application that allows the user to make a BDX createUploadJob call in the Sandbox environment. Response details (success or failure) are displayed on the console.
The application expects the user's sanbox token to be present in the app.config file.
The application has been written in C# using the Visual Studio 2005 environment.Consuming BulkDataExchange 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 - BulkDataExchangeService.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://webservices.sandbox.ebay.com/BulkDataExchangeService?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>
|
4. Make sure that the endpoint address in the app.config file is https://webservices.sandbox.ebay.com/BulkDataExchangeService. Also ensure that the tag underneath the custom binding definition is <httpsTransport> instead of <httpTransport>
5. Comment out the anyField field and the associated property in the BaseServiceResponse class in the BulkDataExchangeService.cs file.
6. Add a reference to System.ServiceModel and System.ServiceModel.Channels
7. The project is now ready for making the different BDX calls available.
Below is a code snippet that shows how to make a call to the createUploadJob function. Download the sample application for details about the code.
BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient("BulkDataExchangeServiceSOAP"); 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", BulkDataExchangeService"); 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", "createUploadJob"); //Create the request CreateUploadJobRequest req = new CreateUploadJobRequest(); //Supply additional parameters //The UUID must be unique. Once used, you can't use it again req.UUID = System.Guid.NewGuid().ToString(); //Specify job type req.uploadJobType = "AddFixedPriceItem"; req.fileType = FileType.XML; //Get the response CreateUploadJobResponse resp = client.createUploadJob(req); // Examine the response to determine success/failure ... } |
Additional Resources