WCF Endpoint Error: Could not find default endpoint element
Asked Answered
R

3

6

So here is my problem. I have a client that is utilized within a service, and when I test said service using the built-in test host in Visual studio, all of the service contracts are available. But, when I try to test one of the service contracts, Visual studio spits out the following error

Could not find default endpoint element that references contract 'TestServiceReference.ITestService' 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.

Now, I know the immediate and obvious answer is to check my config to make sure that my endpoint is correct, but that is the thing, it is correct. I checked both the web.config for the service implementing the client, and the app.config for the client. Both endpoints are correct(at least I think they are).

Here is the web.config endpoint:

<endpoint address="http://testServiceRepo/TestServices/TestService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService"
            contract="TestServiceReference.ITestService"
            name="BasicHttpBinding_ITestService" />

Here is the app.config endpoint:

<endpoint address="http://testServiceRepo/TestServices/TestService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService"
            contract="TestServiceReference.ITestService"
            name="BasicHttpBinding_ITestService" />

The endpoints are the exactly the same, and they both reference TestServiceReference.ITestService. So, I am at a loss here. What would you guys suggest?

Thanks for any help!

Reducer answered 27/7, 2015 at 19:40 Comment(1)
Can you post the entire client config? It might happen that you have two endpoint in the client or you declare a bindingconfiguration but you haven't used properly.Harrovian
S
19

This error can arise if you are calling the service in a class library and calling the class library from another project. In this case you will need to include the WS configuration settings into the main projects app.config if its a winapp or web.config if its a web app. how you are testing it ? Did you tried to create client proxy/class using svcutil and then test these methods. it also generates require configuration in output,config file which you can use.

Sumatra answered 28/7, 2015 at 2:38 Comment(2)
This ended up being the solution. I needed to mirror some of the config settings in the app.config to the web.config. Specifically, I needed to mirror the bindings.Reducer
This was exactly the problem for me too.Anaclinal
U
0

Try settings like this:

client config:

        <basicHttpBinding>
            <binding name="BasicHttpBinding_ITestService" />
        </basicHttpBinding>

        <client>
            <endpoint 
                    address="http://testServiceRepo/TestServices/TestService.svc"
                    binding="basicHttpBinding" 
                    bindingConfiguration="BasicHttpBinding_ITestService"
                    contract="TestServiceReference.ITestService"
                    name="BasicHttpBinding_ITestService" />
        </client>

server config:

        <basicHttpBinding>
            <binding name="BasicHttpBinding_ITestService" />
        </basicHttpBinding>

        <behaviors>
          <serviceBehaviors>
            <behavior name="testBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>

        <services>
            <service behaviorConfiguration="testBehavior"  name="TestServiceReference.TestService">
                <endpoint
                          address=""
                          binding="basicHttpBinding"
                          bindingConfiguration="BasicHttpBinding_ITestService"
                          contract="TestServiceReference.ITestService" 
                          name="BasicHttpBinding_ITestService" />
            </service>
        </services>

EDIT

Note: Actually if you are using service reference (generated proxy) it is enough to fix the settings of service, delete the content of <system.serviceModel> tag in client, and add/update your service reference. It will fix up your settings in the client's config file.

Undulant answered 28/7, 2015 at 2:8 Comment(0)
E
0

For me this exact issue happened when I accidentally 'fixed' the WCF endpoint as

 <client>
        <endpoint 
                address="http://testServiceRepo/TestServices/Testservice.svc"
                binding="basicHttpBinding" 
                bindingConfiguration="BasicHttpBinding_ITestService"
                contract="TestServiceReference.ITestService"
                name="BasicHttpBinding_ITestService" />
    </client>

instead of

 <client>
        <endpoint 
                address="http://testServiceRepo/TestServices/TestService.svc"
                binding="basicHttpBinding" 
                bindingConfiguration="BasicHttpBinding_ITestService"
                contract="TestServiceReference.ITestService"
                name="BasicHttpBinding_ITestService" />
    </client>

(notice the lowercase 's' in the word TestService first address example)

This was for a c# project

Eugenle answered 1/10, 2020 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.