2011-05-04 115 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" />--> 

現在的作品!