ありがとうございました。これにより、指定されたタイプのチャネルを指定されたエンドポイント・アドレスに作成することができます。
これは、WCFサービス用のプロキシを作成する方法の1つです。非常に基本的な例は次のとおりです
using System;
using System.ServiceModel;
[ServiceContract()]
interface IService
{
[OperationContract()]
string GetData(string inputString);
}
public class ConcreteService : IService
{
public string GetData(String inputString)
{
return "you enetered :" + inputString;
}
}
public class Test
{
static void Main()
{
// Create a channel factory.
BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress("http://localhost/ConcreteService/Ep1");
ChannelFactory<IMath> myChannelFactory = new ChannelFactory<IService>(myBinding, myEndpoint);
// Create a channel.
IService wcfClient1 = myChannelFactory.CreateChannel();
string output = wcfClient1.GetData("abc");
((IClientChannel)wcfClient1).Close();
}
}
この詳細については、hereを参照してください。
私はちょうどChannelFactoryが役立つかどうか知りたいですか?工場パターンでWCFクライアントが必要です。 – user3883423
チャネルファクトリは、サービスが実装されているインターフェイスのみを必要とし、サービスへのサービス参照を追加する必要はありません。 – Agalo