Skip to content

Getting Started

Alex edited this page Jul 3, 2019 · 13 revisions

Getting Started with the Genesis API C# Client Library

1. Choose the correct package version based on the API Compatibility Chart

2. Import the correct Nuget Package to your project

3a. If using an on premises API Add the following to your projects app.config

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IFoodEditService"
                     maxReceivedMessageSize="20000000"
                     maxBufferPoolSize="20000000"
                     >
                <security mode="None" />
            </binding>
            <binding name="WSHttpBinding_IFoodQueryService"
                     maxReceivedMessageSize="20000000"
                     maxBufferPoolSize="20000000">
                <security mode="None" />
            </binding>
            <binding name="WSHttpBinding_ILabelImageService"
                     maxReceivedMessageSize="20000000"
                     maxBufferPoolSize="20000000">
                <security mode="None" />
            </binding>
            <binding name="WSHttpBinding_IFoodBuilderService"
                     maxReceivedMessageSize="20000000"
                     maxBufferPoolSize="20000000">
                <security mode="None" />
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:80/soap/FoodEditService.svc"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFoodEditService"
                  contract="Esha.Genesis.Services.Client.IFoodEditService"
                  name="WSHttpBinding_IFoodEditService" />
        <endpoint address="http://localhost:80/soap/FoodQueryService.svc"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFoodQueryService"
                  contract="Esha.Genesis.Services.Client.IFoodQueryService"
                  name="WSHttpBinding_IFoodQueryService" />
        <endpoint address="http://localhost:80/soap/LabelImageService.svc"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILabelImageService"
                  contract="Esha.Genesis.Services.Client.ILabelImageService"
                  name="WSHttpBinding_ILabelImageService" />
        <endpoint address="http://localhost:80/soap/FoodBuilderService.svc"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFoodBuilderService"
                  contract="Esha.Genesis.Services.Client.IFoodBuilderService"
                  name="WSHttpBinding_IFoodBuilderService" />
    </client>
</system.serviceModel>

3b. If using Esha Cloud API Create your clients as follows

var binding = new WSHttpBinding();
binding.SendTimeout = new TimeSpan(0,1,15);
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

var endpointAdress = new EndpointAddress("https://api.eshacloud.com:<custnumber>/SOAP/FoodQueryService.svc");

using (var client = new FoodQueryServiceClient(binding, endpointAdress))
{
	client.ClientCredentials.UserName.UserName = "username@eshacloud";
	client.ClientCredentials.UserName.Password = "password";
	
	// Add User Code Here
}

4. Visit our pages on the services: FoodEditService, FoodQueryService, LabelImageService, FoodBuilderService to see how to use the clients.

Clone this wiki locally