我正在尝试使用 eBay Finding API 发送高级搜索请求并返回结果。我在下面包含了我的代码。
出于某种原因,当我到达以下行时:
FindItemsAdvancedResponse response = service.findItemsAdvanced(request);
名为“响应”的对象将返回为空。
我不确定我哪里出错了,并且没有从调用中抛出异常service.findItemsAdvanced()
如果您能看一下并提供任何建议,我将不胜感激。
这是我的program.cs,直到出现问题
程序.cs
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using EbayParser.com.ebay.developer;
using System.Net;
namespace EbayParser
{
class Program
{
static void Main(string[] args)
{
try
{
// Creating an object to the BestMatchService class
CustomFindingService service = new CustomFindingService();
service.Url = "http://svcs.sandbox.ebay.com/services/search/FindingService/v1";
com.ebay.developer.FindItemsAdvancedRequest request = new EbayParser.com.ebay.developer.FindItemsAdvancedRequest();
//Create Filter Objects
com.ebay.developer.ItemFilter filterEndTimeFrom = new EbayParser.com.ebay.developer.ItemFilter();
com.ebay.developer.ItemFilter filterEndTimeTo = new EbayParser.com.ebay.developer.ItemFilter();
com.ebay.developer.ItemFilter filterCatID = new EbayParser.com.ebay.developer.ItemFilter();
//Set Values for each filter
filterEndTimeFrom.name = EbayParser.com.ebay.developer.ItemFilterType.EndTimeFrom;
filterEndTimeFrom.value = new string[] { "" };
filterEndTimeTo.name = EbayParser.com.ebay.developer.ItemFilterType.EndTimeTo;
filterEndTimeTo.value = new string[] { "" };
filterCatID.name = EbayParser.com.ebay.developer.ItemFilterType.EndTimeFrom;
filterCatID.value = new string[] { "" };
//Create the filter array
com.ebay.developer.ItemFilter[] itemFilters = new EbayParser.com.ebay.developer.ItemFilter[3];
//Add Filters to the array
itemFilters[0] = filterCatID;
itemFilters[1] = filterEndTimeFrom;
itemFilters[2] = filterEndTimeTo;
request.itemFilter = itemFilters;
request.keywords = "ipod";
// Creating response object
FindItemsAdvancedResponse response = service.findItemsAdvanced(request);
这是名为“CustomFindingService.cs”的类的代码
CustomFindingService.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using EbayParser.com.ebay.developer;
namespace EbayParser
{
class CustomFindingService : FindingService
{
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
try
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
request.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords");
request.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "FindingService");
request.Headers.Add("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP11");
request.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
return request;
}
catch (Exception ex)
{
throw ex;
}
}
}
}