Home
Find the answer to your question
How to consume and use eBay Trading Service using .NET framework 4
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.Configuration; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel.Channels; using System.ServiceModel; using eBayTrading_WSDL_Sample.eBayAPIInterfaceService;
namespace eBayTrading_WSDL_Sample { class Program { static void Main(string[] args) { string signinURL = "https://api.sandbox.ebay.com/wsapi"; string callname = "GeteBayOfficialTime"; string siteID = "0"; string appID = "YOUR_APPID_HERE"; string version = "768"; string eBayToken = "YOUR_TOKEN _HERE”; string endpointURL = signinURL + "?callname=" + callname + "&siteid=" + siteID + "&appid=" + appID + "&version=" + version + "&routing=default";
eBayAPIInterfaceClient service = new eBayAPIInterfaceClient("eBayAPI", endpointURL);
EndpointAddress address = new EndpointAddress(endpointURL); service.Endpoint.Address = address; GeteBayOfficialTimeRequestType request = new GeteBayOfficialTimeRequestType(); request.Version = version; request.WarningLevelSpecified = true; request.WarningLevel = WarningLevelCodeType.High; CustomSecurityHeaderType cred = new CustomSecurityHeaderType(); cred.eBayAuthToken = eBayToken; GeteBayOfficialTimeResponseType res = service.GeteBayOfficialTime(ref cred, request); Console.WriteLine("Ack: " + res.Ack.ToString()); Console.WriteLine("Official Time is: " + res.Timestamp); Console.ReadLine();
} } }
|
App.Config file entries |
<?xml version="1.0" encoding="utf-8" ?> <configuration>
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="eBayAPISoapBinding" 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="163840" maxBytesPerRead="4096" maxNameTableCharCount="163840" /> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> <binding name="eBayAPISoapBinding1" 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="163840" maxBytesPerRead="4096" maxNameTableCharCount="163840" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="https://api.ebay.com/wsapi" binding="basicHttpBinding" bindingConfiguration="eBayAPISoapBinding" contract="eBayAPIInterfaceService.eBayAPIInterface" name="eBayAPI" /> </client> </system.serviceModel> </configuration>
|
Note:
Please see the attachment for a sample console application to make GeteBayOfficialTime call.