Home
Find the answer to your question
How to consume and use ProductService using .NET framework
The following is the code sample for getOrderPayoutDetails call using C#.NET
Code in the Program.cs file |
using System; using System.Collections.Generic; using System.Text; using System.Data; using ProductAPI_Sample.ProductServiceWSDL;
namespace ProductAPI_Sample { class Program { static void Main(string[] args) { CustomProductService service = new CustomProductService(); service.Url = @"http://svcs.sandbox.ebay.com/services/marketplacecatalog/ProductService/v1";
GetProductCompatibilitiesRequest request = new GetProductCompatibilitiesRequest(); request.productIdentifier = new ProductIdentifier(); request.productIdentifier.ePID = "76715700"; PaginationInput page = new PaginationInput(); page.entriesPerPageSpecified = true; page.entriesPerPage = 5; page.pageNumberSpecified = true; page.pageNumber = 1; request.paginationInput = page;
GetProductCompatiblitiesResponse response = service.getProductCompatibilities(request); Console.WriteLine("Ack: " + response.ack); if (response.ack == AckValue.Success) { foreach (Product products in response.compatibilityDetails) { Console.WriteLine("Property Name " + "\t" + "Value" + "\t"); foreach (PropertyValue property in products.productDetails) { if ((property.value[0].Item).GetType() == typeof(StringValue)) { Console.WriteLine(property.propertyName + "\t" + ((StringValue)(property.value[0].Item)).value.ToString()); } if ((property.value[0].Item).GetType() == typeof(NumericValue)) { Console.WriteLine(property.propertyName + "\t" + ((NumericValue)(property.value[0].Item)).value.ToString()); } } Console.WriteLine(); } }
Console.ReadLine(); } } }
|
Code in the CustomProductService.cs file |
using System; using System.Collections.Generic; using System.Text; using ProductAPI_Sample.ProductServiceWSDL; using System.Net;
namespace ProductAPI_Sample { public class CustomProductService : ProductService { protected override System.Net.WebRequest GetWebRequest(Uri uri) { try { HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri); request.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "ProductService"); request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "getProductCompatibilities"); request.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "YOUR_APP_ID_HERE"); request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US"); return request; } catch (Exception ex) { throw ex; } } } }
|
Note:
Please see the attachment for a sample console application to make getProductCompatibilities call.
The sample is developed using the VS 2005 and the latest ProductService WSDL
http://developer.ebay.com/webservices/product/latest/ProductService.wsdl