WCF Endpoint Error: Could not find default endpoint item

So here's my problem. I have a client that is being used in a service and when I test said service with the built-in test node in Visual Studio, all service contracts are available. But, when I try to check one of the service contracts, Visual Studio spits out the following error:

Could not find a default endpoint element that references the contract "TestServiceReference.ITestService" in the client configuration section of the ServiceModel. This may be because the configuration file was not found for your application, or because a leaf item matching this contract was not found in the client item.

Now I know that the immediate and obvious answer is to check my configuration to make sure my endpoint is correct, but that is what 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 exactly the same and they both refer to TestServiceReference.ITestService. So I'm at a loss here. What would you suggest?

Thanks for any help!

+3


source to share


2 answers


This error can occur if you call a service in a class library and call the class library from another project. In this case, you will need to include the WS configuration settings in the main projects app.config if it is winapp or web.config if it is a web application. how do you test it? Have you tried to create a client proxy / class using svcutil and then test these methods. it also generates the required configuration in the output config file you can use.



+5


source


Try the following settings:

Client configuration:

        <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. In fact, if you are using a service link (generated proxy), it is enough to correct the service settings, remove the tag content <system.serviceModel>

on the client, and add / update the service link. It will set your preferences in the client config file.

0


source







All Articles