我写了一个简单的wp7应用程序。它使用wcf服务和文件来存储用户提供的数据。 我可以成功运行应用程序没有错误,但我得到一个运行时错误: “无法找到合同'ServiceReference1.IService1'的端点配置部分,因为找到了该合同的多个端点配置。请按名称指示首选端点配置部分” acf包含以下端点配置集
<services>
<service name="WcfDataWallet.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="WcfDataWallet.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
有人可以帮助我吗
答案 0 :(得分:3)
我刚才有同样的问题。我只在VS 2010中为我的项目添加了1个服务引用,但是,我注意到在web.config中添加了2个端点
我刚刚评论了第二个端点,因为我很确定我不需要它。
之前
<endpoint address="http://web_services.u.aco/ServicesLocations/1_1/LocationsService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILocationsService"
contract="LocationService.ILocationsService" name="WSHttpBinding_ILocationsService" />
<endpoint address="http://web_services.u.aco/ServicesLocations/1_1/LocationsService.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILocationsService"
contract="LocationService.ILocationsService" name="BasicHttpBinding_ILocationsService" />
更改为:
<endpoint address="http://web_services.u.aco/ServicesLocations/1_1/LocationsService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILocationsService"
contract="LocationService.ILocationsService" name="WSHttpBinding_ILocationsService" />
<!--<endpoint address="http://web_services.u.aco/ServicesLocations/1_1/LocationsService.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILocationsService"
contract="LocationService.ILocationsService" name="BasicHttpBinding_ILocationsService" />-->
立即行动!
答案 1 :(得分:0)
试试这个
MyClientProxy proxy = new MyClientProxy("endpoint name"); eg EndPointNameXXX
其中“端点名称”应指向客户端配置文件中的一个端点。
<endpoint address="http://[SERVER]/Service"
binding="basicHttpBinding" bindingConfiguration="bindingConfig"
contract="IXXXX.YYYY" name="EndPointNameXXX" />