title: WCF Service Error on Client Service Test - SVCUtil
body: <p>I created a WCF service which compiles fine and published ok; I created a web app to test the WCF service and initially when using <code>svcutil.exe</code> it created the source file but not the config file. So I added the service as a service reference and that looked fine until I tried to run the client app. The following error showed up:</p>
  <pre><code>Could not find default endpoint element that 
  references contract 'ServiceReference1.IService1' 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.
  </code></pre>
  <p>I figured its something wrong with the web.config file and searching for posts I found that I needed to copy the service model section from the service config file to the client test web config file. This did not help.</p>
  <h3>WCF Service config file</h3>
  <pre><code>&lt;configuration&gt;
  
  &lt;system.web&gt;
  &lt;compilation debug=&quot;true&quot; strict=&quot;false&quot; explicit=&quot;true&quot; targetFramework=&quot;4.0&quot; /&gt;
  &lt;/system.web&gt;
  &lt;system.serviceModel&gt;
  &lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&quot;true&quot; /&gt;
  &lt;bindings&gt;
    &lt;webHttpBinding&gt;
      &lt;binding name=&quot;webHttpBinding&quot; crossDomainScriptAccessEnabled=&quot;true&quot; /&gt;
    &lt;/webHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;behaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name=&quot;web&quot;&gt;
        &lt;webHttp /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name=&quot;webHttpBehavior&quot;&gt;
        &lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults=&quot;true&quot; /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
   &lt;/behaviors&gt;
    &lt;services&gt;
    &lt;service behaviorConfiguration=&quot;webHttpBehavior&quot; name=&quot;WcfInstanceRules2.Service1&quot;&gt;
      &lt;endpoint address=&quot;mex&quot; 
       binding=&quot;webHttpBinding&quot; bindingConfiguration=&quot;webHttpBinding&quot;      
  
      contract=&quot;WcfInstanceRules2.IService1&quot; behaviorConfiguration=&quot;web&quot;/&gt;
    &lt;/service&gt;
   &lt;/services&gt;
   &lt;/system.serviceModel&gt;
   &lt;system.webServer&gt;
  &lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;/&gt;
  &lt;/system.webServer&gt;
  </code></pre>
     
  <h3>WebApp Test Config file</h3>
  <pre class="lang-xml prettyprint-override"><code>    &lt;configuration&gt;
      &lt;connectionStrings&gt;
      &lt;add name=&quot;ApplicationServices&quot;
      connectionString=&quot;data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true&quot;
           providerName=&quot;System.Data.SqlClient&quot; /&gt;
      &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;compilation debug=&quot;true&quot; strict=&quot;false&quot; explicit=&quot;true&quot; targetFramework=&quot;4.0&quot; /&gt;
      &lt;authentication mode=&quot;Forms&quot;&gt;
        &lt;forms loginUrl=&quot;~/Account/Login.aspx&quot; timeout=&quot;2880&quot; /&gt;
      &lt;/authentication&gt;
      &lt;membership&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name=&quot;AspNetSqlMembershipProvider&quot; type=&quot;System.Web.Security.SqlMembershipProvider&quot; connectionStringName=&quot;ApplicationServices&quot;
               enablePasswordRetrieval=&quot;false&quot; enablePasswordReset=&quot;true&quot; requiresQuestionAndAnswer=&quot;false&quot; requiresUniqueEmail=&quot;false&quot;
               maxInvalidPasswordAttempts=&quot;5&quot; minRequiredPasswordLength=&quot;6&quot; minRequiredNonalphanumericCharacters=&quot;0&quot; passwordAttemptWindow=&quot;10&quot;
               applicationName=&quot;/&quot; /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;profile&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name=&quot;AspNetSqlProfileProvider&quot; type=&quot;System.Web.Profile.SqlProfileProvider&quot; connectionStringName=&quot;ApplicationServices&quot; applicationName=&quot;/&quot;/&gt;
        &lt;/providers&gt;
      &lt;/profile&gt;
       &lt;roleManager enabled=&quot;false&quot;&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name=&quot;AspNetSqlRoleProvider&quot; type=&quot;System.Web.Security.SqlRoleProvider&quot; connectionStringName=&quot;ApplicationServices&quot; applicationName=&quot;/&quot; /&gt;
          &lt;add name=&quot;AspNetWindowsTokenRoleProvider&quot; type=&quot;System.Web.Security.WindowsTokenRoleProvider&quot; applicationName=&quot;/&quot; /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
      &lt;/system.web&gt;
      &lt;system.webServer&gt;
       &lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;/&gt;
      &lt;/system.webServer&gt;
      &lt;system.serviceModel&gt;
       &lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&quot;true&quot; /&gt;
       &lt;bindings&gt;
        &lt;webHttpBinding&gt;
          &lt;binding name=&quot;webHttpBinding&quot; crossDomainScriptAccessEnabled=&quot;true&quot; /&gt;
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name=&quot;webHttpBehavior&quot;&gt;
            &lt;webHttp /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name=&quot;webHttpBehavior&quot;&gt;
            &lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults=&quot;true&quot; /&gt;
          &lt;/behavior&gt;
          &lt;behavior name=&quot;&quot;&gt;
            &lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults=&quot;false&quot; /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
        &lt;/behaviors&gt;
         &lt;services&gt;
         &lt;service behaviorConfiguration=&quot;webHttpBehavior&quot; name=&quot;WcfInstanceRules2.Service1&quot;&gt;
          &lt;endpoint address=&quot;mex&quot; binding=&quot;webHttpBinding&quot;   
       bindingConfiguration=&quot;webHttpBinding&quot; 
       contract=&quot;WcfInstanceRules2.IService1&quot; behaviorConfiguration=&quot;webHttpBehavior&quot;/&gt;
        &lt;/service&gt;
       &lt;/services&gt;
       &lt;/system.serviceModel&gt;
      &lt;/configuration&gt;
  </code></pre>