2011-05-04 91 views
3

我写了一个简单的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

试试这个

MyClientProxy proxy = new MyClientProxy("endpoint name"); eg EndPointNameXXX 

其中“端点名称”应指向客户端配置文件中的一个端点。

<endpoint address="http://[SERVER]/Service" 
       binding="basicHttpBinding" bindingConfiguration="bindingConfig" 
       contract="IXXXX.YYYY" name="EndPointNameXXX" /> 
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" />--> 

现在的作品!