Skip to main content
Published: January 11 2011, 5:26:00 AMUpdated: November 28 2020, 9:08:36 PM

How to call FindingService API from .Net Framework 4.

  1. Add a service reference to the Finding API definition file (please use the latest version of the WSDL file)
     
    http://developer.ebay.com/webservices/Finding/latest/FindingService.wsdl
  2. Create an object for FindingServicePortTypeClient class –

FindingServicePortTypeClient client = new FindingServicePortTypeClient()

  1. Create an object for the required request type.
       FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();  
  2. Provide value for the required properties.
        request. keywords = “canon”; // for example 
  3. Create an object to the required response type. For example,
       FindItemsByKeywordsResponse response = service.findItemsByKeywords(request);  
  4. Explore the response object for response data.
  5. Increasing the maxBufferSize and maxReceivedMessageSize in the App.Config file to 655360

The following is the code sample for findItemsByKeywords API call using C#.NET framework 4.

Code in the Program.cs file

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using DOTNET4_FindingService_Sample.FindingServiceWebReference;

using System.ServiceModel.Channels;

using System.ServiceModel;

 

namespace DOTNET4_FindingService_Sample

{

    class Program

    {

        static void Main(string[] args)

        {

            using (FindingServicePortTypeClient client = new FindingServicePortTypeClient())

            {

                MessageHeader header = MessageHeader.CreateHeader("CustomHeader", "", "");

                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_APP_ID_HERE");

                    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 = "canon";

                    FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);

                    foreach (var item in response.searchResult.item)

                    {

                        Console.WriteLine(item.title);

                    }

                    Console.ReadLine();

                }

            }

        }

    }

}

 

 

App.Config

 

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

<configuration>

    <system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <binding name="FindingServiceSOAPBinding" closeTimeout="00:01:00"

                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="655360" maxBufferPoolSize="524288" maxReceivedMessageSize="655360"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                    useDefaultWebProxy="true">

                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="Transport">

                        <transport clientCredentialType="None" proxyCredentialType="None"

                            realm="" />

                        <message clientCredentialType="UserName" algorithmSuite="Default" />

                    </security>

                </binding>

            </basicHttpBinding>

        </bindings>

        <client>

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

                binding="basicHttpBinding" bindingConfiguration="FindingServiceSOAPBinding"

                contract="FindingServiceWebReference.FindingServicePortType"

                name="FindingServiceSOAPPort" />

        </client>

    </system.serviceModel>

</configuration>

 

 

 

 

 

 

 

 

 

 

How well did this answer your question?
Answers others found helpful