お互いにアクセス可能な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.svcとhttp://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>
右!ありがとうございました!それがトリックでした。クライアントセクションがあるとは考えていませんでした。今私はエラーメッセージを理解していますが、実際には明らかに「[...] ServiceModelクライアント設定セクション」です。今、このエラーを解決する方法を理解する: "ChannelFactoryのエンドポイントには有効なアドレスが指定されている必要があります" – Nebula
この返答のおかげで、私のコードは今動作します。 – Nebula