Wcf – Could not find default endpoint element that references contract in the ServiceModel client configuration section

iiswcf

I am trying to develop a WCF service and host it in IIS. But when I try to consume service, I get this error.

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.

I have tested the WCF service using the WCF Test Client and I was able to invoke it successfully.

But the same doesn't work when I consume it. Kindly help me to sort out this.

web.config I have used in WCF:

<!--WCF web config-->
    <system.serviceModel>    
        <services>    
          <service name="ProductServiceLibrary.RuelaService">    
            <endpoint address="" binding="wsHttpBinding" contract="RuelaService.IService1">    
              <identity>    
                <dns value="localhost" />    
              </identity>    
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>    
        </services>    

        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>

When I consume the WCF service, I make use of this app.config:

<system.serviceModel>
   <bindings>
      <basicHttpBinding>
         <binding name="BasicHttpBinding_IService1" />
      </basicHttpBinding>
   </bindings>
   <client>
       <!--URL where I have hosted my WCF http://localhost:9999/Service1.svc-->
       <endpoint name="BasicHttpBinding_IService1" 
           address="http://localhost:9999/Service1.svc" 
           binding="basicHttpBinding"
           bindingConfiguration="BasicHttpBinding_IService1"  
           contract="ServiceReference1.IService1" />
   </client>
</system.serviceModel>


  [1]: http://i.stack.imgur.com/djQoN.png

Best Answer

The service appears to be exposing a contract that differs to the client configuration.

Service:

<endpoint address="" binding="wsHttpBinding" 
   contract="RuelaService.IService1">   

Client:

 <endpoint name="BasicHttpBinding_IService1" 
           address="http://localhost:9999/Service1.svc" 
           binding="basicHttpBinding"
           bindingConfiguration="BasicHttpBinding_IService1"  
           contract="ServiceReference1.IService1" />

So there is a mismatch somewhere.

Related Topic