2016-10-06 8 views
0

WCF serviceを消費しようとすると以下のエラーが発生します。 I looked into this issue and both name and contract values are same in both config filesWCFサービスを消費するときにエンドポイント要素を見つけることができません

は、名前のエンドポイント要素ServiceModelクライアント 構成セクションの「BasicHttpBinding_IService1」 と契約「ServiceReference1.IService1」が見つかりませんでした。これは、アプリケーションにコンフィグレーションファイル が見つかりませんでした。または、 に一致するエンドポイント要素がクライアント要素に見つかりませんでした。

WCFサービスは私のソリューションでは自由に使用できますが、私は同じソリューションの下で別のクラスのリベラルプロジェクトでそれを消費しようとしています。

Client.config

<endpoint address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" 
    contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> 
</client> 

WCFの設定ファイル

<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service name="WcfServiceLibrary1.Service1"> 
     <host> 
      <baseAddresses> 
      <add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true. Set to false before deployment 
      to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

</configuration> 
+0

あなたはサービスがブラウザで利用可能であることがわかりますか? – silver

+0

ブラウザで利用可能です。 – simbada

答えて

1

あなたは、あなたの質問に言ったように私は、元の答えのために、このリンクを参照してくださいYou are trying to consume the service in a class library and calling the class library from another project."」あなたの問題を考える。link

問題を解決するにはd。クライアントのバインディングの詳細をメインの呼び出し元プロジェクトの設定ファイルにコピーします。

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IService1" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" 
     contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> 
    </client> 
    </system.serviceModel> 
+0

これで問題が解決するかどうか確認してください。 – simbada

+0

ありがとう、それは私のために働いた。 – simbada

0

サービス名と契約の完全な名前空間でフルネーム識別子を試してください。

<service name="SOLUTIONNAME.WcfServiceLibrary1.Service1"> 
    <endpoint address="" binding="basicHttpBinding" 
    contract="SOLUTIONNAME.WcfServiceLibrary1.IService1"> 
    ... 

</service> 
関連する問題