Skip to main content
Published: September 04 2012, 2:33:00 PMUpdated: November 28 2020, 10:37:53 PM

How can I make a simple findHalfItems call using the .NET (C#)?

Summary

findHalfItems C# sample



Detailed Description

This sample is using Microsoft Visual Studio 2010, eBay .NET SDK Version 779 - .NET 2.0 Point Release

Requirements:

After opening a C# project,

-  Add a service reference to Half Finding Service, http://developer.ebay.com/webservices/half-finding/latest/HalfFindingService.wsdl

-  Make sure Target Framework is NOT set to .NET Framework Client Profile

 

1.  Code Sample (This sample was in a windows form project in a button click):

       

/*
© 2012-2013 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php
*/ 

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

//make sure to set max values to be able to handle large message size and large strings (such as <Description>)

binding.MaxReceivedMessageSize = int.MaxValue;

binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;

HalfFindingServiceReference.HalfFindingServicePortClient client = new HalfFindingServiceReference.HalfFindingServicePortClient(

binding,

new EndpointAddress("https://svcs.ebay.com/services/half/HalfFindingService/v1"));

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 APPNAME HERE");

httpRequestProperty.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findHalfItems");

httpRequestProperty.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "HalfFindingService");

httpRequestProperty.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");

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

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

HalfFindingServiceReference.FindItemsRequest halfrequest = new HalfFindingServiceReference.FindItemsRequest();

//productID based on ISBN

HalfFindingServiceReference.ProductIDType productID = new HalfFindingServiceReference.ProductIDType();

productID.typeSpecified = true;

productID.type = HalfFindingServiceReference.ProductIDCodeType.ISBN;

productID.Value = "YOUR ISBN HERE";

halfrequest.productID = productID;

HalfFindingServiceReference.findHalfItemsResponse response = new HalfFindingServiceReference.findHalfItemsResponse();

response.findHalfItemsResponse1 = client.findHalfItems(halfrequest);

response.findHalfItemsResponse1.ack.ToString();

//handle response here.....

         



Additional Resources

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