I’m trying to use the eBay Finding API to send an advanced search request and return the results. I have included my code below.
For some reason when I get to the following line:
FindItemsAdvancedResponse response = service.findItemsAdvanced(request);
the object called “response” is coming back as null.
I’m not sure where I’m going wrong and no exception is being thrown from the call to service.findItemsAdvanced()
If you could take a look and offer any advice at all I would be most grateful.
Here is my program.cs up until the problem
Progam.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);
and here is the code for the class called “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;
}
}
}
}
2
Answers
If you leave any of the filters blank in the filter array you will get the SOA Operation Header missing exception whether or not you have included the headers correctly.
You should check the filters are not null before applying them to your request.
I had exactly the same problem when I went from finding by keywords to using the advanced method. I spent a while scratching my head myself but it turned out to have a simple fix:
Your header
X-EBAY-SOA-OPERATION-NAME
readsfindItemsByKeywords
. Changing it tofindItemsAdvanced
should do the trick.