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

    Question

  •  


    i have another question

     

    i have made a client application added a web reference to the WCF service , and instatiated an object from the proxy class, now when i call a method that only returns a string an exception occurs and this is its description:

     

     

      "Could not find default endpoint element that references contract 'ProductServices.ProductServices.IProductService' 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"

     

     

    the client used to work fine, and all was ok, i dont know what happened, i have checked the Web.config at the WCF Service and nothing changed,the endpoint and all is in place ..

     

    why does this error occur?

    Thursday, August 14, 2008 11:05 AM

Answers

  •  

    Finally after investigating and literally finding nothing on web to help, i have recollected all the actions i have done and found the reason for this error, btw there are many reasons posted online and all of them are true, now the thing happened with me is

     

    My WCF_Service inherited from

     

    ' Inherits System.ServiceModel.ClientBase(Of IProductService)

     

    i commented this line

    and the 'Could not find default endpoint element that references contract ...' exception vanished

     

    now i have inherited from this base class in order to perform Constructor Chaining to my base inherited class (the ClientBase Class) in order to send to it the End Point Configuration Name...

     

    Now can anyone tell me why did this happen, and how can i overcome this problem in order to use multiple end points were i can send each configuration name to the constructor in the WCF Client?

     

    Basem Sayej

     

    Sunday, August 17, 2008 9:19 PM

All replies

  • Hi,

     

     Could you please post the relevant part of your configuration files?

     

     --larsw

     

    Thursday, August 14, 2008 11:17 AM
    Moderator
  •  

    <configuration>

    <system.serviceModel>

    <services>

    <service name="ProductServices.ProductServices.ProductServiceImpl" behaviorConfiguration="ProductsBehavior">

    <endpoint address=""

    binding="basicHttpBinding"

    contract="ProductServices.ProductServices.IProductService" />

    </service>

    </services>

     

    <behaviors>

    <serviceBehaviors>

    <behavior name="ProductsBehavior">

    <serviceMetadata httpGetEnabled="true" />

    <serviceDebug includeExceptionDetailInFaults="true" />

    </behavior>

    </serviceBehaviors>

    </behaviors>

    </system.serviceModel>

    </configuration>

     

    Can anyone help

     

    the App.Config of the WCF Service CLient

    is :

     

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

    <configSections>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

    <section name="ProductServicesClient.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

    </sectionGroup>

    </configSections>

    <system.diagnostics>

    <sources>

    <!-- This section defines the logging configuration for My.Application.Log -->

    <source name="DefaultSource" switchName="DefaultSwitch">

    <listeners>

    <add name="FileLog"/>

    <!-- Uncomment the below section to write to the Application Event Log -->

    <!--<add name="EventLog"/>-->

    </listeners>

    </source>

    </sources>

    <switches>

    <add name="DefaultSwitch" value="Information" />

    </switches>

    <sharedListeners>

    <add name="FileLog"

    type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"

    initializeData="FileLogWriter"/>

    <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->

    <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->

    </sharedListeners>

    </system.diagnostics>

    <system.serviceModel>

    <client>

    <endpoint address="http://esense-bsayej.esensesoftware.local:99/ProductServices/ProductServices.svc"

    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProductsService" contract="ProductServices.ProductServices.IProductService"

    name="BasicHttpBinding_IProductsService" />

    </client>

    </system.serviceModel>

    <applicationSettings>

    <ProductServicesClient.My.MySettings>

    <setting name="ProductServicesClient_ProductServices_ProductServiceImpl"

    serializeAs="String">

    <value>http://esense-bsayej.esensesoftware.local:99/ProductServices/ProductServices.svc</value>

    </setting>

    </ProductServicesClient.My.MySettings>

    </applicationSettings>

    </configuration>

    Thursday, August 14, 2008 11:25 AM
  • An hour ago I experienced a similar problem. My app was working fine connecting to a wcf. Then, to the best of my recollection, I did two things. I added another endpoint for a diiferent wcf  in the client element in the web.config. Also, I changed the target framework in both the website which calls the wcf and the service from 2.0 to 3.5. All of a sudden, I can't connect and I get the ''can't find default endpoint'' error. Any help welcomed.
    Thursday, August 14, 2008 2:22 PM
  • Well the common thing between what you did and what i did, is that i added another endpoint and i added another web reference to a different Site for the same WCF Service on the Client Application.. however i removed the end point and i removed the reference to the other WCF and i removed everything related in the App.Config...

     

    i dont know whats the problem i hope someone helps, my imagination says that something is added at the configuration of the WCF Service(thought i cant see any difference in its config file) an end point or something that is waiting to be mapped to the deleted end point we added, i hope someone on this blog helps due Smile

     

    if you find the solution plz tell me Smile

    Thursday, August 14, 2008 2:35 PM
  • Hi,

    You can try couple of things:

    1. When you generate the proxy on the client, use the name of the endpoint like:

    Client proxy = new Client("BasicHttpBinding_IProductsService");

    2. Change the name if you can to a simple *<namespace>.<class>*. Just to avoid understanding what is missing here. See if you can avoid different names than same *ProductServices.ProductServices.<contract>*

     

    More importantly, since you are saying it worked once, if you are using mini web server, check if it is running. can you as well post the client proxy creation class...

    Sunday, August 17, 2008 12:04 PM
  •  

    Dear Phani_Tpk

     

    i have redone everything in a new solution and new WCF Service : WCF_Service with the namespace WCF_Service_NameSpace and made my client app( windows console app) but same thing is happening

    this is by reference.vb

     

    Option Strict Off

    Option Explicit On

    Imports System

    Imports System.ComponentModel

    Imports System.Diagnostics

    Imports System.Web.Services

    Imports System.Web.Services.Protocols

    Imports System.Xml.Serialization

     

    Namespace WCF_Service_Proxy

    '''<remarks/>

    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.1433"), _

    System.Diagnostics.DebuggerStepThroughAttribute(), _

    System.ComponentModel.DesignerCategoryAttribute("code"), _

    System.Web.Services.WebServiceBindingAttribute(Name:="BasicHttpBinding_IProductService", [Namespace]:="http://tempuri.org/")> _

    Partial Public Class ProductServiceImpl

    Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

    Private BasemOperationCompleted As System.Threading.SendOrPostCallback

    Private ProductListOperationCompleted As System.Threading.SendOrPostCallback

    Private GetProductOperationCompleted As System.Threading.SendOrPostCallback

    Private CurrentStockLevelOperationCompleted As System.Threading.SendOrPostCallback

    Private ChangeStockLevelOperationCompleted As System.Threading.SendOrPostCallback

    Private useDefaultCredentialsSetExplicitly As Boolean

    '''<remarks/>

    Public Sub New()

    MyBase.New

    Me.Url = Global.WCF_Service_Client.My.MySettings.Default.WCF_Service_Client_WCF_Service_Proxy_ProductServiceImpl

    If (Me.IsLocalFileSystemWebService(Me.Url) = true) Then

    Me.UseDefaultCredentials = true

    Me.useDefaultCredentialsSetExplicitly = false

    Else

    Me.useDefaultCredentialsSetExplicitly = true

    End If

    End Sub

    Public Shadows Property Url() As String

    Get

    Return MyBase.Url

    End Get

    Set

    If (((Me.IsLocalFileSystemWebService(MyBase.Url) = true) _

    AndAlso (Me.useDefaultCredentialsSetExplicitly = false)) _

    AndAlso (Me.IsLocalFileSystemWebService(value) = false)) Then

    MyBase.UseDefaultCredentials = false

    End If

    MyBase.Url = value

    End Set

    End Property

    Public Shadows Property UseDefaultCredentials() As Boolean

    Get

    Return MyBase.UseDefaultCredentials

    End Get

    Set

    MyBase.UseDefaultCredentials = value

    Me.useDefaultCredentialsSetExplicitly = true

    End Set

    End Property

    '''<remarks/>

    Public Event BasemCompleted As BasemCompletedEventHandler

    '''<remarks/>

    Public Event ProductListCompleted As ProductListCompletedEventHandler

    '''<remarks/>

    Public Event GetProductCompleted As GetProductCompletedEventHandler

    '''<remarks/>

    Public Event CurrentStockLevelCompleted As CurrentStockLevelCompletedEventHandler

    '''<remarks/>

    Public Event ChangeStockLevelCompleted As ChangeStockLevelCompletedEventHandler

    '''<remarks/>

    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/IProductService/Basem", RequestNamespace:="http://tempuri.org/", ResponseNamespace:="http://tempuri.org/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _

    Public Function Basem() As <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> String

    Dim results() As Object = Me.Invoke("Basem", New Object(-1) {})

    Return CType(results(0),String)

    End Function

    '''<remarks/>

    Public Overloads Sub BasemAsync()

    Me.BasemAsync(Nothing)

    End Sub

    '''<

    .

    .

    .

    .

    .

     

    .due to length restriction

    Sunday, August 17, 2008 6:17 PM
  •  

    Finally after investigating and literally finding nothing on web to help, i have recollected all the actions i have done and found the reason for this error, btw there are many reasons posted online and all of them are true, now the thing happened with me is

     

    My WCF_Service inherited from

     

    ' Inherits System.ServiceModel.ClientBase(Of IProductService)

     

    i commented this line

    and the 'Could not find default endpoint element that references contract ...' exception vanished

     

    now i have inherited from this base class in order to perform Constructor Chaining to my base inherited class (the ClientBase Class) in order to send to it the End Point Configuration Name...

     

    Now can anyone tell me why did this happen, and how can i overcome this problem in order to use multiple end points were i can send each configuration name to the constructor in the WCF Client?

     

    Basem Sayej

     

    Sunday, August 17, 2008 9:19 PM