我有一个具有以下端点的服务:
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
name="SomeServiceDotNetEndpoint" contract="Contracts.ISomeService" />
当我将此服务引用添加到另一个项目时,应用程序配置文件显示以下客户端端点:
<endpoint address="http://test.example.com/Services/SomeService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISomeService"
contract="SomeService.ISomeService" name="BasicHttpBinding_ISomeService" />
现在,具有该名称的端点BasicHttpBinding_ISomeService
永远不会在服务的 Web 配置文件中定义。当我尝试使用以下代码创建新的通道工厂时:
var someServiceChannelFactory = new ChannelFactory<ISomeService>("SomeServiceDotNetEndPoint", endpoint);
它失败了,告诉我该地址没有匹配的合约/端点。我也试过使用"BasicHttpBinding_ISomeService"
,我得到了同样的错误。
Could not find endpoint element with name 'SomeServiceDotNetEndPoint' and
contract 'SomeService.ISomeService' 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 name could be found
in the client element.
那么,BasicHttpBinding_ISomeService
从哪里来,为什么我的原始端点名称被覆盖,我怎样才能让服务识别我试图命中的端点?