我正在尝试绑定一个asp.net页面到另一个网站托管的wcf服务,
客户端的web. config文件具有代码:
<endpoint address="http://localhost:1670/webhost/CustomersService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_ICustomersService" contract="CustomersService.ICustomersService" name="BasicHttpBinding_ICustomersService"/>
</client>
该服务的web. config文件具有代码:
<endpoint address="" binding="wsHttpBinding" contract="CustomerServiceLibrary1.ICustomersService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
错误是:
错误1参考. svcmap:system.serviceModel/bindings/wsHttpBind的绑定没有名为'wsHttpBinding_ICustomersService'的配置绑定。这是bindingConfiguration的无效值。(C:\用户\劳拉\文档\Visual Studio 2010\Projects\CustomerServiceDemo\WebClient\web.config第25行)App_WebReferences/CustomersService/。
客户端配置的以下部分bindingConfiguration="wsHttpBinding_ICustomersService"
告诉它应该使用名称为“wsHttpBinding_ICustomersService”的绑定配置,您的客户端web. config中有该名称的绑定配置吗?
下面的文章解释了WCF和绑定http://msdn.microsoft.com/en-us/magazine/cc163394.aspx
但这部分应该是你想要的
<configuration>
<system.serviceModel>
<services>
<service name=”ChatService”>
<endpoint address=”http://localhost:8080/chat”
binding=”basicHttpBinding”
bindingConfiguration=”basicConfig”
contract=”ChatLibrary.IChat” />
...
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name=”basicConfig” messageEncoding=”Mtom”>
<security mode=”Transport”/>
</binding>
</basicHttpBinding>
...
</bindings>
</system.serviceModel>
</configuration>
注意“绑定”部分
我得到了同样的异常
"system. serviceModel/bindings/basicHttpBind的绑定没有名为'BasicHttpBinding_ITestService'的配置绑定。这是bindingConfiguration的无效值。"
当我指定并在代码中添加具有basicHttpBind的endpoint名称时,我的问题得到了解决
TestServiceClient obj = new TestServiceClient("BasicHttpBinding_ITestService");