Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# Soap Client Issue - more than one endpoint configuration for th at contract was found

Tags:

c#

soap

I am trying to write a simple c# console application to test the SOAP API from here: https://www.imailtest.co.uk/webservice/imail_api.asmx?wsdl (or https://www.imailtest.co.uk/webservice/imail_api.asmx to see the api methods)

So, I added this reference and tried to invoke 2 api methods (Authentiacate & ProcessPrintReadyPDF) calls on it and got this error:

Error : An endpoint configuration section for contract 'ServiceReference1.imail_ apiSoap' could not be loaded because more than one endpoint configuration for th at contract was found. Please indicate the preferred endpoint configuration sect ion by name.

Here's my C# Code:

static void Main(string[] args) {     // Anticipate Error     try     {         // Generate SOAP Client         ServiceReference1.imail_apiSoapClient soapClient = new ServiceReference1.imail_apiSoapClient();          // Login         Console.WriteLine("Authenticating");         soapClient.Authenticate(iMailUser, iMailPass);          // Proceed If PDF File Exists         if (File.Exists(PDFFile))         {             // Upload PDF File To iMail             Console.WriteLine("Uploading PDF File");             soapClient.ProcessPrintReadyPDF(File.ReadAllBytes(PDFFile), "", true);              // Test Complete             Console.WriteLine("Done");         }         else         {             // Log Error             Console.WriteLine("PDF File [{0}] Does Not Exists", PDFFile);         }     }     catch (Exception ex)     {         // Log Error         Console.WriteLine("Error : "+ ex.Message);     }      // End Test     Console.WriteLine("Press any key to continue ...");     Console.ReadKey(); } 

This is how I added the service reference to my console app:

screenshot

Any ideas?

like image 366
Latheesan Avatar asked Jul 09 '13 09:07

Latheesan


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C full form?

Originally Answered: What is the full form of C ? C - Compiler . C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in 1972.

How old is the letter C?

The letter c was applied by French orthographists in the 12th century to represent the sound ts in English, and this sound developed into the simpler sibilant s.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.


2 Answers

In your App.config you can see some thing like this

 <client>       <endpoint address="https://www.imailtest.co.uk/webservice/imail_api.asmx "         binding="basicHttpBinding" bindingConfiguration="xxxxxxxxxx"         contract="xxxxxxxxxx" name="xxxxxxxxxxxxx" />       <endpoint address="https://www.imailtest.co.uk/webservice/imail_api.asmx"         binding="customBinding" bindingConfiguration="xxxxxxxxxxxxx"         contract="xxxxxxxxxxx" name="xxxxxxxxxxxxx" />   </client> 

remove the second endpoint and now it should be like this

<client>       <endpoint address="https://www.imailtest.co.uk/webservice/imail_api.asmx "         binding="basicHttpBinding" bindingConfiguration="xxxxxxxxxxxxx"         contract="xxxxxxxxxxxxxx" name="xxxxxxxxxxxxxxx" />         </client> 

now run the code , hope your code works fine

like image 194
sudil ravindran pk Avatar answered Sep 19 '22 02:09

sudil ravindran pk


I believe the problem is solved via defining the contract name like so (based on my screenshot):

ServiceReference1.imail_apiSoapClient soapClient =  new ServiceReference1.imail_apiSoapClient("imail_apiSoap"); 

Now, I am no longer getting an error and the api appears to be working.

like image 36
Latheesan Avatar answered Sep 22 '22 02:09

Latheesan