连接到WCF服务,我得到这个错误,而试图从AC#客户端访问IIS(本地)托管的WCF服务:无法从客户端
无法与名称查找端点元素“X”并在ServiceModel客户端配置部分签订合同'合同 名称'。这可能是 ,因为找不到您的应用程序的配置文件或 ,因为在 客户端元素中找不到与此名称匹配的端点元素。
这是客户端的app.config中(它是一个NUnit的夹具只是为了测试连接):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_MyWs" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/MyWs/MyWs.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyWs"
contract="MyServiceSvc.IMyWs"
name="BasicHttpBinding_MyWs" />
</client>
</system.serviceModel>
</configuration>
如果我浏览
https://localhost/MyWs/MyWs.svc?wsdl
我得到正确的输出,因此服务器部分工作正常。
此外,我可以用soapUI测试我的ws,所以问题必须在客户端,也许在app.config中。
我的客户端代码,以防万一有人想tolook吧:
[TestFixture]
public class MyWsProxyFixture
{
private readonly MyWsClient _client = new MyWsClient();
[Test]
public void ProxyCreation()
{
Assert.IsNotNull(_client);
}
//More tests here
}
更有趣,完全相同的配置和客户端在另一台机器的工作原理。是的,它是真实的。我自己无法相信,但事实确实如此。
你能提出一些提示或建议来解决这个问题吗?
谢谢!
PS:客户端的服务引用很好。
请提供乌尔解决方案的结构,这样我就可以相应地更新我的答案。 – 2013-03-07 11:24:58
我的解决方案:1使用其他各种组件(类库项目)和客户端的类库项目的wcf服务 – andreapier 2013-03-07 11:34:52
您可以发布您的客户端代码吗?您是否还在使用WCF服务的添加服务引用,或者您是否从WSDL生成代理并将其包含在客户端项目中?另外在客户端配置中,我可以看到合同值有一个名称空间,并希望界面位于客户端项目中的同一名称空间中,以及 – Rajesh 2013-03-07 14:39:54