C# 在 ServiceModel 客户端配置部分中找不到引用合同“IAuthenticationService”的默认端点元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19659210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not find default endpoint element that references contract 'IAuthenticationService' in the ServiceModel client configuration section
提问by Ranjith Kumar Nagiri
I tried creating a simple WCF application, I haven't changed any of the existing default configurations. I have tried consuming the service using the TestClient
generated by using svcutil.exe
. It is showing an error message "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."
I tried putting endpoint to localhost:port number/test.svc but its showing the same error.
我尝试创建一个简单的 WCF 应用程序,但没有更改任何现有的默认配置。我曾尝试使用TestClient
通过 using 生成的服务来使用服务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:port number/test.svc 但它显示了相同的错误。
this code is being shown after i execute the web test client. I couldnt trace out the error after searching for long hours over internet
在我执行 Web 测试客户端后,将显示此代码。在互联网上搜索了很长时间后,我无法找出错误
Here is my testClients clientdll.config
这是我的 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>
采纳答案by Shiva Saurabh
try removing the end points there and use
尝试删除那里的端点并使用
compilation debug=true
in web.config. then after trying
在 web.config 中。然后在尝试之后
svcutil.exe http://your_wsdl
you will generate an output.config. Try putting in servicemodel nodes replacing your client website or application with the output.config service model. It will work
您将生成一个 output.config。尝试放入 servicemodel 节点,用 output.config 服务模型替换您的客户端网站或应用程序。它会工作
回答by Sam Leach
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 name of the binding or contract will be wrong. You confing needs to look something like
绑定或合同的名称将是错误的。你 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>
Make sure the bindingConfiguration
matches the binding name
. In the above example Binding1
确保bindingConfiguration
匹配binding name
. 在上面的例子中Binding1