Could not find default endpoint element that references contract in the ServiceModel client configuration section

  • Thread starter Thread starter Fabs1977
  • Start date Start date
F

Fabs1977

Guest
I have a Windows Forms app targeting the .Net 4.0 framework. I need to connect to a web service to upload a payment file for an accounting system, so what I did was to add the service reference (NIWS_NIF Service) and then I execute the following code

Dim client As New SagePay.sagePayServiceReference.NIWS_NIFClient()

Dim fileToken As String = client.BatchFileUpload(serviceKey, batchFile)

As soon as the first line executes, I get the following error:

"Could not find default endpoint element that references contract 'sagePayServiceReference.INIWS_NIF' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

This is what my app.config file looks like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_INIWS_NIF">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="NIWS_NIF Service"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INIWS_NIF"
contract="sagePayServiceReference.INIWS_NIF" name="BasicHttpBinding_INIWS_NIF" />
</client>
</system.serviceModel>
</configuration>

I should add that I have implemented this code as a class library (a DLL) which I've referenced in my main project. So I've added this project as a reference to my main project, and then from my main project, I call the above code...

Any ideas?


Fabricio Rodriguez - Pretoria, South Africa

Continue reading...
 
Back
Top