Search code examples
c#wcfwcf-endpoint

WCF service endpoint configuration doesn't like the binding attribute


In my web.config file I have the following service defined:

<services>
  <service name="ShareYourWage.Service.WageService" behaviorConfiguration ="metadataBehavior">
    <endpoint>
      binding="basicHttpBinding"
      contract="ShareYourWage.Service.IWageService">
    </endpoint>
  </service>
</services>

Yet, when I debug the service, the test client throws the following error:

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

and digging into the specific error points to the endpoint section shows the following error:

The configuration section cannot contain a CDATA or text element.

I've Googled this error and the MSDN site and have used their examples and still have this problem. A 2nd pair of eyes would be big help, thanks!


Solution

  • You accidentally closed your endpoint tag before the binding and contract attributes.

    Remove the '>' at the end of <endpoint>.

    You want it to be like this:

    <endpoint
      binding="basicHttpBinding"
      contract="ShareYourWage.Service.IWageService">
    </endpoint>
    

    If you're using Visual Studio or some other XML-aware text editor to modify the config files, the syntax highlighting can be helpful for spotting these kinds of problems.