Could not find default endpoint element

Viewed 382072

I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:

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

Searching for this error tells me to use the full namespace in the contract. Here's my app.config with full namespace:

<client>
  <endpoint address="http://192.168.100.87:7001/soap/IMySOAPWebService"
            binding="basicHttpBinding" bindingConfiguration="IMySOAPWebServicebinding"
            contract="Fusion.DataExchange.Workflows.IMySOAPWebService" name="IMySOAPWebServicePort" />
</client>

I'm running XP local (I mention this because a number of Google hits mention win2k3) The app.config is copied to app.exe.config, so that is also not the problem.

Any clues?

34 Answers

Having tested several options, I finally solved this by using

contract="IMySOAPWebService"

i.e. without the full namespace in the config. For some reason the full name didn't resolve properly

I had the same problem, but changing the contract namespace didn't work for me. So I tried a .Net 2 style web reference instead of a .Net 3.5 service reference. That worked.

To use a Web reference in Visual Studio 2008, click on 'Add Service Reference', then click 'Advanced' when the dialog box appears. In that you will find an option that will let you use a Web reference instead of a Service reference.

The namespace in your config should reflect the rest of the namespace path after your client's default namespace (as configured in the project properties). Based on your posted answer, my guess is that your client is configured to be in the "Fusion.DataExchange.Workflows" namespace. If you moved the client code to another namespace you would need to update the config to match the remaining namespace path.

In my case, I Add service in both start up project and projects that use service with the same name. It worked...

In my case I had renamed app.config to [appname].exe.config manually. This ended up adding an extra .config suffix to the file name. Solution was to rename it to [appname].exe to eliminate the extra .config extension.

There was another way I found the right endpointConfigurationName.

Adding the endpointConfigurationName as below

EservicesNew.ServiceClient eservicenew = new EservicesNew.ServiceClient("BasicHttpsBinding_IService");

Find the endpointConfigurationName as below

After adding the Web Reference, open the configuration.svcinfo file from the generated reference file.

enter image description here

There is two endpoints found and I used the right endpoint bindingConfiguration value which is BasicHttpsBinding_IService

enter image description here

Related