Error : Could not find default endpoint element

Photo by Erik Mclean on Unsplash

Error : Could not find default endpoint element

Error :

Could not find default endpoint element that references contract 'XXX.xxx' 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 error can arise if you are calling the service in a class library and calling the class library from another project.

If you are using web app, then you have to copy app.config of class library configuration content to web.config of web project.

Here is the config details. It contains bindings and client nodes.

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="smsnnPortBinding" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://api.google.com/SMS"
            binding="basicHttpBinding" bindingConfiguration="smsnnPortBinding"
            contract="XXX.xxx" name="smsnnPort" />
    </client>
  </system.serviceModel>

Be careful, contract="XXX.xxx" name must be same as error indicated