无法在ServiceModel客户端配置部分中找到引用合同“IAuthenticationService”的默认端点元素

时间:2013-10-29 13:12:23

标签: c# wcf error-handling

我尝试创建一个简单的WCF应用程序,我没有更改任何现有的默认配置。我尝试使用TestClient生成的svcutil.exe来使用该服务。它显示错误消息"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:端口号/ 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>

2 个答案:

答案 0 :(得分:8)

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

 compilation debug=true 
web.config中的

。然后尝试

svcutil.exe http://your_wsdl

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

答案 1 :(得分:6)

  

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

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

<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