1

I am creating a WCF Service. It is my first one. I am receiving the error:

Could not find default endpoint element that references contract 'WCFClient.IWCFClient' in the ServiceModel client configuration section.

I have tried switching around endpoint names and such, and deleting/recreating the service reference. I can't seem to figure out what the problem is.

Application Config:

<bindings>
    <basicHttpBinding>
         <binding name="BasicHttpBinding_IWCFClient" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
    </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:4295/Services/WCFClient.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFClient"
            contract="WCFClient.IWCFClient" name="BasicHttpBinding_IWCFClient" />
    </client>

Service Config:

 <services>
  <service behaviorConfiguration="WCFGraphicManagementTool.Services.WCFClientBehavior"
    name="WCFGraphicManagementTool.Services.WCFClient">
      <endpoint address="" name="BasicHttpBinding_IWCFClient" binding="basicHttpBinding" contract="WCFGraphicManagementTool.Contracts.IWCFClient">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFGraphicManagementTool.Services.WCFClientBehavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        <serviceThrottling maxConcurrentCalls="120" maxConcurrentSessions="120" maxConcurrentInstances="120" />
        <serviceMetadata httpGetEnabled="True" />
        <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>    
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
Matt Schubert
  • 1,003
  • 1
  • 10
  • 12
  • How do you create the client proxy? – Ladislav Mrnka Apr 29 '11 at 13:26
  • WCFClient.WCFClientClient WCFClient = new WCFClient.WCFClientClient(); This is the line that it errors out on. – Matt Schubert Apr 29 '11 at 13:38
  • Is it the only endpoint defined in client config? What happens if you call: `var client = new WCFClient.WCFClientClient("BasicHttpBinding_IWCFClient");` – Ladislav Mrnka Apr 29 '11 at 13:42
  • That is the only endpoint in my config. I tried the above line and it came back with the same error basically: Could not find endpoint element with name 'BasicHttpBinding_IWCFClient' and contract 'WCFClient.IWCFClient' in the ServiceModel client configuration section – Matt Schubert Apr 29 '11 at 13:46
  • Are you sure that client configuration is in the executable's config? – Ladislav Mrnka Apr 29 '11 at 13:53
  • I just figured it out. I needed to add it to the project's web.config also. It was in the service's, but not the project. Thanks for your help. – Matt Schubert Apr 29 '11 at 14:01

2 Answers2

1

I just figured it out. I needed to add it to the project's web.config also. It was in the service's, but not the project.

Matt Schubert
  • 1,003
  • 1
  • 10
  • 12
0

This is normally due to a mismatch between the service name/namespace that is specified in the config file and either the contract name on the source code or markup of the service file. Normally happens after you create a new service via Visual Studio and then rename the service/namespace.

Right-click on the .svc file in the solution explorer and select 'View Markup'

Check if the 'Service' attribute value is correct. Check if both namespace and name match the ones you have assigned.

Should be something like this:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFGraphicManagementTool.Services.WCFClient" CodeBehind="WCFClient.svc.cs" %>
Sergio Vicente
  • 980
  • 1
  • 10
  • 18