【问题标题】:Could not find default endpoint element that references contract 'IAuthenticationService' in the ServiceModel client configuration section在 ServiceModel 客户端配置部分中找不到引用合同“IAuthenticationService”的默认端点元素
【发布时间】:2013-11-08 15:59:39
【问题描述】:

我尝试创建一个简单的 WCF 应用程序,我没有更改任何现有的默认配置。我尝试使用svcutil.exe 生成的TestClient 来使用该服务。它显示一条错误消息"Could not find default endpoint element that references contract 'IAuthenticationService' 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." 我尝试将端点放置到 localhost:port number/test.svc 但它显示相同的错误。

此代码在我执行 Web 测试客户端后显示。在网上搜索了很长时间后,我无法找出错误

这是我的 testClients clientdll.config

<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="wsHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" establishSecurityContext="true" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:2490/AuthenticationService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpBinding"
                contract="IAuthenicationService" name="wsHttpBinding">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

【问题讨论】:

  • 请在帖子中包含您的客户端 app.config
  • @MarvinSmit 我已经编辑发布了我在执行测试客户端后得到的配置。
  • 错误是指服务合同“IService1”不存在。查看您的配置,这正是问题所在。您只需为“IAuthenicationService”配置一个端点。
  • 不,我的配置相同,我尝试过创建两个项目,一个是实时的,另一个是用于执行测试,经过多次测试后它们都无法工作@MarvinSmit
  • IService1 @MarvinSmit 没有问题

标签: c# wcf error-handling


【解决方案1】:

这可能是因为找不到您的配置文件 应用程序,或者因为没有匹配此合同的端点元素 可以在客户端元素中找到。

绑定或合同的名称将是错误的。你的 confing 需要看起来像

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Binding1" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://foo" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="Service.MyService" name="MyService" />
    </client>
  </system.serviceModel>

确保bindingConfigurationbinding name 匹配。在上面的例子中Binding1

【讨论】:

    【解决方案2】:

    尝试删除那里的端点并使用

     compilation debug=true 
    

    在 web.config 中。然后在尝试之后

    svcutil.exe http://your_wsdl
    

    您将生成一个 output.config。尝试使用 output.config 服务模型替换您的客户端网站或应用程序的 servicemodel 节点。它会工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-11
      • 2011-11-01
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 2012-03-11
      • 1970-01-01
      • 2011-01-12
      相关资源
      最近更新 更多