Hopefully this small piece of code will save you some grief when integrating the EBAY Finding API into your application.

Here are  the Steps –

Step 1 – Create a C# Console Application and Add a Service Reference

Step 2 – Enter Code to Call findItemsByKeywords with the Ebay SOA Custom Headers

using System;

using System.ServiceModel;

using System.ServiceModel.Channels;

using EbayTestWCFConsoleApplication.EbayServiceReference;

namespace EbayTestWCFConsoleApplication

{

class Program

{

static void Main(string[] args)

{


using
(FindingServicePortTypeClient client = new FindingServicePortTypeClient())

{

MessageHeader header = MessageHeader.CreateHeader(“My-CustomHeader”,http://www.mycustomheader.com”,“Custom Header”);


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

{

OperationContext.Current.OutgoingMessageHeaders.Add(header);


HttpRequestMessageProperty
httpRequestProperty = new HttpRequestMessageProperty();

httpRequestProperty.Headers.Add(“X-EBAY-SOA-SECURITY-APPNAME”, “YOUR-APPID”);

httpRequestProperty.Headers.Add(“X-EBAY-SOA-OPERATION-NAME”, “findItemsByKeywords”);

httpRequestProperty.Headers.Add(“X-EBAY-SOA-GLOBAL-ID”, “EBAY-US”);

OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;


FindItemsByKeywordsRequest
request = new FindItemsByKeywordsRequest();


request.keywords = “ipod”;


FindItemsByKeywordsResponse
response = client.findItemsByKeywords(request);


foreach
(var item in response.searchResult.item)

{

Console.WriteLine(item.title);

}

}

}


Console
.ReadKey();

}

}

}

Step 3 – Tweak Response Message size in App.Config and Press F5

You must change maxBufferSize=”655360” and maxReceivedMessageSize=”655360” to same ‘increased’ value.  In this example I have simply added another “0”.

<?xml version=1.0 encoding=utf-8 ?>

<configuration>

<configSections>

</configSections>

<system.serviceModel>

<bindings>

<customBinding>

<binding name=FindingServiceSOAPBinding>

<textMessageEncoding maxReadPoolSize=64 maxWritePoolSize=16

messageVersion=Soap12 writeEncoding=utf-8>

<readerQuotas maxDepth=32 maxStringContentLength=8192 maxArrayLength=16384

maxBytesPerRead=4096 maxNameTableCharCount=16384 />

</textMessageEncoding>

<httpsTransport manualAddressing=false maxBufferPoolSize=524288

maxReceivedMessageSize=655360 allowCookies=false authenticationScheme=Anonymous

bypassProxyOnLocal=false hostNameComparisonMode=StrongWildcard

keepAliveEnabled=true maxBufferSize=655360 proxyAuthenticationScheme=Anonymous

realm=“” transferMode=Buffered unsafeConnectionNtlmAuthentication=false

useDefaultWebProxy=true requireClientCertificate=false>

<extendedProtectionPolicy policyEnforcement=Never />

</httpsTransport>

</binding>

</customBinding>

</bindings>

<client>

<endpoint address=https://svcs.ebay.com/services/search/FindingService/v1

binding=customBinding bindingConfiguration=FindingServiceSOAPBinding

contract=EbayServiceReference.FindingServicePortType name=FindingServiceSOAPPort />

</client>

</system.serviceModel>

</configuration>

Please excuse the code formatting, but you’ll get the idea if you cut and paste it in.

Take Care,

Matt

using System;

using System.ServiceModel;

using System.ServiceModel.Channels;

using EbayTestWCFConsoleApplication.EbayServiceReference;

namespace EbayTestWCFConsoleApplication

{

class Program

{

static void Main(string[] args)

{

using (FindingServicePortTypeClient client = new FindingServicePortTypeClient())

{

MessageHeader header = MessageHeader.CreateHeader(“My-CustomHeader”,http://www.mycustomheader.com&#8221;,“Custom Header”);

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

{

OperationContext.Current.OutgoingMessageHeaders.Add(header);

HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();

httpRequestProperty.Headers.Add(“X-EBAY-SOA-SECURITY-APPNAME”, “PriceIns-e439-4e18-8678-7ecd8f6f26ba”);

httpRequestProperty.Headers.Add(“X-EBAY-SOA-OPERATION-NAME”, “findItemsByKeywords”);

httpRequestProperty.Headers.Add(“X-EBAY-SOA-GLOBAL-ID”, “EBAY-US”);

OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();

request.keywords = “ipod”;

FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);

foreach (var item in response.searchResult.item)

{

Console.WriteLine(item.title);

}

}

}

Console.ReadKey();

}

}

}