1

First of all: I know, there are a lot of threads like this and be sure I READ THEM! But I constantly run into this error.

An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll but was not handled in user code

Additional information: Could not find default endpoint element that references contract 'getApplicationInformation.IgetApplicationInformation' 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.

I developed a SharePoint (2013) solution and need to consume serveral webservices from a normal aspx-webpage. The webservices are running fine (tested with the WCF testclient of VS2013).

Now I added the webservices to my SharePoint solution via rightclick on "References" -> "Add Service Reference" -> gave the URL to the box -> webservice was found properly - no problem. After the webservice was added VS2013 created the app.config (as expected) with the following xml:

<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
  <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IgetApplications" />
            <binding name="BasicHttpBinding_IgetApplicationInformation" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://devserver:82/WebServices/getApplications/getApplications.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IgetApplications"
            contract="getApplications.IgetApplications" name="BasicHttpBinding_IgetApplications" />
        <endpoint address="http://devserver:82/WebServices/getApplications/getApplicationInformation.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IgetApplicationInformation"
            contract="getApplicationInformation.IgetApplicationInformation"
            name="BasicHttpBinding_IgetApplicationInformation" />
    </client>
  </system.serviceModel>
</configuration>

So far so good. Now I am "calling" the webservices in C# like this:

getApplicationInformation.IgetApplicationInformationClient getJopAppInfoClient = new getApplicationInformation.IgetApplicationInformationClient();

This is the point, where I get the error. So I used Google to get the problem solved. I read that the problem may is that the xml above wasn´t added automatically to the web.config of the SharePoint WebApp and it wasn´t. I added the xml to the web.config -> next try to run my code -> same error. Googled again and maybe the error is that the name of the Service Reference in the SP solution is not equal to the contract name in the app.config but it was -> no issue there. And again Google ... Found the issue that the given xml above maybe was wrong (created through VS2013) and I should use the xml of the WCF testclient to get this thing done. This is what the WCF testclient creates:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IgetApplicationInformation"
                sendTimeout="00:05:00" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://devserver:82/WebServices/getApplications/getApplicationInformation.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IgetApplicationInformation"
            contract="IgetApplicationInformation" name="BasicHttpBinding_IgetApplicationInformation" />
    </client>
  </system.serviceModel>
</configuration>

Yes, it is only one now. So I added this to my SP WebApp web.config and try to run my code -> still the same error.

This is very frustrating. Due to the fact, that I still develop my webpage where the services are running is on the same server and I publish a newer version locally via VS2013 publish. Due to that the web.config the the webpage wasn´t provided with an xml to the system.servicemodel section so I copied the code given through VS2013 but the error still occurs.

IISRESET or RESTART of my dev machine didn´t helped me out :-D I am sure that I just misunderstand something and doesn´t get the point where I need to provide the right information in the web.config of my SP webapp and the same on the webpage site.

So please, can anybody provide me a detailed solution for that? MANY THANKS!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.