2011-12-21 10 views
2

お互いにアクセス可能な2つのWCFサービスを作成しようとしています。しかし、私はこのエラーメッセージが表示されます: 要求の処理中にサーバーでエラーが発生しました。例外メッセージは、「ServiceModelクライアント構成セクションで契約「AddonWCFService.IService1」を参照するデフォルトエンドポイント要素を見つけることができませんでした。これは、アプリケーションに設定ファイルが見つからなかったか、またはこの契約に一致するエンドポイント要素がクライアント要素に見つかりませんでした。サービスがWCF内の他のサービスのエンドポイントを見つけることができません

は、私は、このサービス

namespace CustomersService 
{ 
    [ServiceContract] 
    public interface ICustomers 
    { 
     [OperationContract] 
     [WebGet] 
     string Test(); 
    } 

    public class Customers : ICustomers 
    { 
     private int m_i = 0; 

     public int GetCounter() 
     { 
      return m_i; 
     } 

     public void Test() 
     { 
      AddonWCFService.Service1Client foo = new AddonWCFService.Service1Client(); 
     } 
    } 
} 

他のサービスからテスト()メソッドを呼び出し

namespace AddonWCFWebservice 
{ 
    [ServiceContract] 
    public interface IService1 
    { 
     [OperationContract] 
     void Init(); 
    } 


    public class Service1 : IService1 
    { 
     public void Init() 
     { 

     } 
    } 
} 

私のWebConfig:

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
     <services> 

      <service behaviorConfiguration="MyserviceBehavior" name="CustomersService.Customers"> 
       <endpoint name="ws" address="ws" binding="wsHttpBinding" contract="CustomersService.ICustomers"/> 
       <endpoint name="" 
          address="" 
          binding="webHttpBinding" 
          contract="CustomersService.ICustomers" 
          behaviorConfiguration="WebBehavior"/> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 
      <service name="AddonWCFWebservice.Service1" behaviorConfiguration="MyserviceBehavior"> 
       <endpoint address="" binding="wsHttpBinding" contract="AddonWCFWebservice.IService1"/> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="MyserviceBehavior"> 
        <serviceMetadata httpGetEnabled="true"/> 
        <serviceDebug includeExceptionDetailInFaults="true"/> 
       </behavior> 
      </serviceBehaviors> 
      <endpointBehaviors> 
       <behavior name="WebBehavior"> 
        <webHttp /> 
       </behavior> 
      </endpointBehaviors> 
     </behaviors> 
    </system.serviceModel> 
    <system.web> 
     <compilation debug="true"/>   
     <customErrors mode="Off"/> 
    </system.web> 
</configuration> 

両方のサービスが同じアクティブディレクトリに存在IIS。 Web参照URLを使用してVS C#プロジェクトにサービス参照を追加しました。つまり、http://www.foobar.baz/Test/Service1.svchttp://www.foobar.baz/Test/Customers.svc

これはおそらく明らかですが、私はWCFビジネス全体にかなり新しいです。ありがとう!

更新:ソリューションは、私のwebconfigにクライアントセクションを追加することでした。また、公共サービスなので、私のセキュリティは別の場所に追加されるので、wsHttpBindingよりもbasicHttpBindingを使用しました。私は、サービスセクションの結合へのクライアントの結合を一致させる必要がありました:basicHttpBinding

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
     <client> 
      <endpoint 
      name="" 
      address="http://demo.mydomain.baz/TestService/Service1.svc" 
      binding="basicHttpBinding" 
      contract="AddonWCFService.IService1" /> 
     </client> 

     <services> 
      <service behaviorConfiguration="MyserviceBehavior" name="CustomersService.Customers"> 
       <endpoint name="ws" address="ws" binding="wsHttpBinding" contract="CustomersService.ICustomers"/> 
       <endpoint name="" 
          address="" 
          binding="webHttpBinding" 
          contract="CustomersService.ICustomers" 
          behaviorConfiguration="WebBehavior"/> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 
      <service name="AddonWCFWebservice.Service1" behaviorConfiguration="MyserviceBehavior"> 
       <endpoint address="" binding="basicHttpBinding" contract="AddonWCFWebservice.IService1"/> 
       <!-- 
       <endpoint address="" 
          binding="webHttpBinding" 
          contract="AddonWCFWebservice.IService1" 
          behaviorConfiguration="WebBehavior"/> 
       --> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 


     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="MyserviceBehavior"> 
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
        <serviceMetadata httpGetEnabled="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="true"/> 
       </behavior> 
      </serviceBehaviors> 
      <endpointBehaviors> 
       <behavior name="WebBehavior"> 
        <webHttp /> 
       </behavior> 
      </endpointBehaviors> 
     </behaviors> 
    </system.serviceModel> 
    <system.web> 
     <compilation debug="true"/>   
     <customErrors mode="Off"/> 
    </system.web> 
</configuration> 

答えて

3

設定の問題は、クライアントの設定がないことです。あなたはサーバの部品しか持っていません。エンドポイントを持つクライアント要素が必要です。ここをクリックしてください:http://msdn.microsoft.com/en-us/library/ms731745.aspx

あなたがあなたの設定スキルについて私はあなたの設定をSvcConfigEditor.exeで開くことをお勧めします。設定されているものがすぐに表示されます。 ここには、C:¥Program Files¥Microsoft SDKs¥Windows¥v6.0A¥Bin¥SvcConfigEditor.exeがあります。 あなたはそれを行います場合 - あなたはどのクライアントが存在しないことがわかります

+0

右!ありがとうございました!それがトリックでした。クライアントセクションがあるとは考えていませんでした。今私はエラーメッセージを理解していますが、実際には明らかに「[...] ServiceModelクライアント設定セクション」です。今、このエラーを解決する方法を理解する: "ChannelFactoryのエンドポイントには有効なアドレスが指定されている必要があります" – Nebula

+0

この返答のおかげで、私のコードは今動作します。 – Nebula

0

両方の私は、あなたの設定ファイルで間違ったサービスコントラクトを指定したと思います。ここ

この行は:それは( "WCF" なし) "AddonService.IService1" のようなものでなければならないとき

<endpoint address="" binding="wsHttpBinding" contract="AddonWCFWebservice.IService1"/>

"AddonWCFWebservice.IService1" として契約を指定します。

+0

を設定し、私は私のプロジェクトファイルのようにAddonWCFWebserviceへのサービス参照の名前空間を変更しました。それでもエラーは残りますが、「ServiceModelクライアント構成セクションで「AddonWCFService.IService1」という契約を参照するデフォルトのエンドポイント要素を見つけることができませんでした。ご覧のとおり、このISはweb.configです。両方のサービスが同じIISアクティブディレクトリにあるという事実と関係がありますか?どのようにこれをデバッグする上の任意のポインター? – Nebula

関連する問題