ClientBase<TChannel> コンストラクター

定義

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
ClientBase<TChannel>()

アプリケーション構成ファイルの既定のターゲット エンドポイントを使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, String, String)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(String, String)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(String, EndpointAddress)

指定したターゲット アドレスとエンドポイント情報を使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, String)

指定したコールバック サービスとエンドポイント構成情報を使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, String, EndpointAddress)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(Binding, EndpointAddress)

指定したバインディングとターゲット アドレスを使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(String)

ClientBase<TChannel>によってアプリケーション構成ファイルで指定された構成情報を使用して、endpointConfigurationName クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext)

双方向会話のコールバック オブジェクトとしてClientBase<TChannel>を使用して、callbackInstance クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(ServiceEndpoint)

指定したClientBase<TChannel>を使用して、ServiceEndpoint クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, ServiceEndpoint)

指定したClientBase<TChannel>オブジェクトとInstanceContext オブジェクトを使用して、ServiceEndpoint クラスの新しいインスタンスを初期化します。

注釈

アプリケーション構成ファイル内のエンドポイント情報から WCF クライアント オブジェクトを作成するために使用します。 コンストラクターの主な関数は、型パラメーターがターゲット サービス コントラクトの型である System.ServiceModel.ChannelFactory<TChannel> を作成することです。

ClientBase<TChannel>()

ソース:
ClientBase.cs
ソース:
ClientBase.cs
ソース:
ClientBase.cs

アプリケーション構成ファイルの既定のターゲット エンドポイントを使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase();
protected ClientBase();
Protected Sub New ()

例外

構成ファイルに既定のエンドポイント情報がないか、ファイル内に複数のエンドポイントがあるか、構成ファイルがありません。

次のコード例は、ClientBase<TChannel> クラスを拡張するSampleServiceClient クラスでクライアントがこのコンストラクターを使用する方法を示しています。

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;

public class Client
{
  public static void Main()
  {
    // Picks up configuration from the config file.
    SampleServiceClient wcfClient = new SampleServiceClient();
    try
    {
        // Making calls.
        Console.WriteLine("Enter the greeting to send: ");
        string greeting = Console.ReadLine();
        Console.WriteLine("The service responded: " + wcfClient.SampleMethod(greeting));

        Console.WriteLine("Press ENTER to exit:");
        Console.ReadLine();

        // Done with service.
        wcfClient.Close();
        Console.WriteLine("Done!");
    }
    catch (TimeoutException timeProblem)
    {
      Console.WriteLine("The service operation timed out. " + timeProblem.Message);
      wcfClient.Abort();
      Console.Read();
    }
    catch(CommunicationException commProblem)
    {
      Console.WriteLine("There was a communication problem. " + commProblem.Message);
      wcfClient.Abort();
      Console.Read();
    }
  }
}


Imports System.ServiceModel
Imports System.ServiceModel.Channels

Public Class Client
  Public Shared Sub Main()
    ' Picks up configuration from the config file.
    Dim wcfClient As New SampleServiceClient()
    Try
        ' Making calls.
        Console.WriteLine("Enter the greeting to send: ")
            Dim greeting = Console.ReadLine()
        Console.WriteLine("The service responded: " & wcfClient.SampleMethod(greeting))

        Console.WriteLine("Press ENTER to exit:")
        Console.ReadLine()

        ' Done with service. 
        wcfClient.Close()
        Console.WriteLine("Done!")
    Catch timeProblem As TimeoutException
      Console.WriteLine("The service operation timed out. " & timeProblem.Message)
      wcfClient.Abort()
      Console.Read()
    Catch commProblem As CommunicationException
      Console.WriteLine("There was a communication problem. " & commProblem.Message)
      wcfClient.Abort()
      Console.Read()
    End Try
  End Sub
End Class

注釈

このコンストラクターを使用して、サービスを呼び出す WCF クライアント オブジェクトを作成します。 このコンストラクターは、型パラメーターをターゲット コントラクトとして使用し、アプリケーション構成ファイルからのバインディングとアドレスの情報を使用します。

適用対象

ClientBase<TChannel>(InstanceContext, String, String)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::String ^ endpointConfigurationName, System::String ^ remoteAddress);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * string * string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpointConfigurationName As String, remoteAddress As String)

パラメーター

callbackInstance
InstanceContext

接続されたサービスからのメッセージをリッスンするためにクライアントが使用するコールバック オブジェクト。

endpointConfigurationName
String

アプリケーション構成ファイル内のエンドポイントの名前。

remoteAddress
String

サービスのアドレス。

例外

コールバック インスタンス、 endpointConfigurationName、または remoteAddressnull

エンドポイントが見つからないか、エンドポイント コントラクトが無効です。

注釈

このコンストラクターを使用して、ターゲット サービスのコールバック コントラクトを実装するサービス オブジェクトを渡し、アプリケーション構成ファイル内のエンドポイントの名前からターゲット エンドポイント情報を決定します (ターゲット値は、クライアント <endpoint> 要素のname属性を見つけることによって見つけます)。指定されたアドレス。

こちらもご覧ください

適用対象

ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)

ソース:
ClientBase.cs
ソース:
ClientBase.cs
ソース:
ClientBase.cs

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, binding As Binding, remoteAddress As EndpointAddress)

パラメーター

callbackInstance
InstanceContext

コールバック サービス。

binding
Binding

サービスを呼び出すバインディング。

remoteAddress
EndpointAddress

サービス エンドポイントのアドレス。

例外

コールバック インスタンス、 binding、または remoteAddressnull

適用対象

ClientBase<TChannel>(String, String)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::String ^ endpointConfigurationName, System::String ^ remoteAddress);
protected ClientBase(string endpointConfigurationName, string remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : string * string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpointConfigurationName As String, remoteAddress As String)

パラメーター

endpointConfigurationName
String

アプリケーション構成ファイル内のエンドポイントの名前。

remoteAddress
String

サービスのアドレス。

例外

endpointConfigurationName または remoteAddressnull

エンドポイントが見つからないか、エンドポイント コントラクトが無効です。

注釈

このコンストラクターを使用して、アプリケーション構成ファイル内のエンドポイントの名前からターゲット エンドポイント情報を確認します (ターゲット値は、クライアント <endpoint> 要素のname属性を見つけることによって配置されます)。

こちらもご覧ください

適用対象

ClientBase<TChannel>(String, EndpointAddress)

指定したターゲット アドレスとエンドポイント情報を使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::String ^ endpointConfigurationName, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : string * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpointConfigurationName As String, remoteAddress As EndpointAddress)

パラメーター

endpointConfigurationName
String

アプリケーション構成ファイル内のエンドポイントの名前。

remoteAddress
EndpointAddress

サービスのアドレス。

例外

endpointConfigurationName または remoteAddressnull

エンドポイントが見つからないか、エンドポイント コントラクトが無効です。

注釈

このコンストラクターを使用して、アプリケーション構成ファイル内のエンドポイントの名前からターゲット エンドポイント情報を確認します (ターゲット値は、クライアント <endpoint> 要素のname属性を見つけることによって配置されます)。

適用対象

ClientBase<TChannel>(InstanceContext, String)

指定したコールバック サービスとエンドポイント構成情報を使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::String ^ endpointConfigurationName);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpointConfigurationName As String)

パラメーター

callbackInstance
InstanceContext

接続されたサービスからのメッセージをリッスンするためにクライアントが使用するコールバック オブジェクト。

endpointConfigurationName
String

アプリケーション構成ファイル内のエンドポイントの名前。

例外

コールバック インスタンスまたは endpointConfigurationNamenull

エンドポイントが見つからないか、エンドポイント コントラクトが無効です。

注釈

このコンストラクターを使用して、ターゲット サービスのコールバック コントラクトを実装するサービス オブジェクトを渡し、クライアント アプリケーション構成ファイルからターゲット エンドポイント情報を決定します。 ターゲット値は、クライアント <endpoint> 要素のname属性を見つけることによって配置されます。

適用対象

ClientBase<TChannel>(InstanceContext, String, EndpointAddress)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::String ^ endpointConfigurationName, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * string * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpointConfigurationName As String, remoteAddress As EndpointAddress)

パラメーター

callbackInstance
InstanceContext

接続されたサービスからのメッセージをリッスンするためにクライアントが使用するコールバック オブジェクト。

endpointConfigurationName
String

アプリケーション構成ファイル内のエンドポイントの名前。

remoteAddress
EndpointAddress

サービスのアドレス。

例外

コールバック インスタンス、 endpointConfigurationName、または remoteAddressnull

エンドポイントが見つからないか、エンドポイント コントラクトが無効です。

注釈

このコンストラクターを使用して、ターゲット サービスのコールバック コントラクトを実装するサービス オブジェクトを渡し、アプリケーション構成ファイル内のエンドポイントの名前からターゲット エンドポイント情報を決定します (ターゲット値は、クライアント <endpoint> 要素のname属性を見つけることによって見つけます)。指定されたアドレス。

こちらもご覧ください

適用対象

ClientBase<TChannel>(Binding, EndpointAddress)

ソース:
ClientBase.cs
ソース:
ClientBase.cs
ソース:
ClientBase.cs

指定したバインディングとターゲット アドレスを使用して、 ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ remoteAddress);
protected ClientBase(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (binding As Binding, remoteAddress As EndpointAddress)

パラメーター

binding
Binding

サービスの呼び出しに使用するバインディング。

remoteAddress
EndpointAddress

サービス エンドポイントのアドレス。

例外

binding または remoteAddressnull

適用対象

ClientBase<TChannel>(String)

ClientBase<TChannel>によってアプリケーション構成ファイルで指定された構成情報を使用して、endpointConfigurationName クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::String ^ endpointConfigurationName);
protected ClientBase(string endpointConfigurationName);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : string -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpointConfigurationName As String)

パラメーター

endpointConfigurationName
String

アプリケーション構成ファイル内のエンドポイントの名前。

例外

指定されたエンドポイント情報が null

エンドポイントが見つからないか、エンドポイント コントラクトが無効です。

注釈

アプリケーション構成ファイルに複数のターゲット エンドポイントがある場合は、このコンストラクターを使用します。 この値は、クライアント <endpoint> 要素のname属性です。

適用対象

ClientBase<TChannel>(InstanceContext)

ソース:
ClientBase.cs
ソース:
ClientBase.cs

双方向会話のコールバック オブジェクトとしてClientBase<TChannel>を使用して、callbackInstance クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext)

パラメーター

callbackInstance
InstanceContext

接続されたサービスからのメッセージをリッスンするためにクライアント アプリケーションが使用するコールバック オブジェクト。

例外

コールバック インスタンスが null

構成ファイルに既定のエンドポイント情報がないか、ファイル内に複数のエンドポイントがあるか、構成ファイルがありません。

次のコード例は、このコンストラクターを SampleDuplexHelloClient クラスと共に使用して、サービスからのメッセージをリッスンするコールバック オブジェクトを渡す方法を示しています。

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;

namespace Microsoft.WCF.Documentation
{
  [CallbackBehaviorAttribute(
   IncludeExceptionDetailInFaults= true,
    UseSynchronizationContext=true,
    ValidateMustUnderstand=true
  )]
  public class Client : SampleDuplexHelloCallback
  {
    AutoResetEvent waitHandle;

    public Client()
    {
      waitHandle = new AutoResetEvent(false);
    }

    public void Run()
    {
      // Picks up configuration from the configuration file.
      SampleDuplexHelloClient wcfClient
        = new SampleDuplexHelloClient(new InstanceContext(this), "WSDualHttpBinding_SampleDuplexHello");
      try
      {
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Enter a greeting to send and press ENTER: ");
        Console.Write(">>> ");
        Console.ForegroundColor = ConsoleColor.Green;
        string greeting = Console.ReadLine();
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Called service with: \r\n\t" + greeting);
        wcfClient.Hello(greeting);
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
        this.waitHandle.WaitOne();
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("Set was called.");
        Console.Write("Press ");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("ENTER");
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.Write(" to exit...");
        Console.ReadLine();
      }
      catch (TimeoutException timeProblem)
      {
        Console.WriteLine("The service operation timed out. " + timeProblem.Message);
        Console.ReadLine();
      }
      catch (CommunicationException commProblem)
      {
        Console.WriteLine("There was a communication problem. " + commProblem.Message);
        Console.ReadLine();
      }
    }
    public static void Main()
    {
      Client client = new Client();
      client.Run();
    }

    public void Reply(string response)
    {
      Console.WriteLine("Received output.");
      Console.WriteLine("\r\n\t" + response);
      this.waitHandle.Set();
    }
  }
}

Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Threading

Namespace Microsoft.WCF.Documentation
  <CallbackBehaviorAttribute(IncludeExceptionDetailInFaults:= True, UseSynchronizationContext:=True, ValidateMustUnderstand:=True)> _
  Public Class Client
      Implements SampleDuplexHelloCallback
    Private waitHandle As AutoResetEvent

    Public Sub New()
      waitHandle = New AutoResetEvent(False)
    End Sub

    Public Sub Run()
      ' Picks up configuration from the configuration file.
      Dim wcfClient As New SampleDuplexHelloClient(New InstanceContext(Me), "WSDualHttpBinding_SampleDuplexHello")
      Try
        Console.ForegroundColor = ConsoleColor.White
        Console.WriteLine("Enter a greeting to send and press ENTER: ")
        Console.Write(">>> ")
        Console.ForegroundColor = ConsoleColor.Green
        Dim greeting As String = Console.ReadLine()
        Console.ForegroundColor = ConsoleColor.White
        Console.WriteLine("Called service with: " & Constants.vbCrLf & Constants.vbTab & greeting)
        wcfClient.Hello(greeting)
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.")
        Me.waitHandle.WaitOne()
        Console.ForegroundColor = ConsoleColor.Blue
        Console.WriteLine("Set was called.")
        Console.Write("Press ")
        Console.ForegroundColor = ConsoleColor.Red
        Console.Write("ENTER")
        Console.ForegroundColor = ConsoleColor.Blue
        Console.Write(" to exit...")
        Console.ReadLine()
      Catch timeProblem As TimeoutException
        Console.WriteLine("The service operation timed out. " & timeProblem.Message)
        Console.ReadLine()
      Catch commProblem As CommunicationException
        Console.WriteLine("There was a communication problem. " & commProblem.Message)
        Console.ReadLine()
      End Try
    End Sub
    Public Shared Sub Main()
      Dim client As New Client()
      client.Run()
    End Sub

    Public Sub Reply(ByVal response As String) Implements SampleDuplexHelloCallback.Reply
      Console.WriteLine("Received output.")
      Console.WriteLine(Constants.vbCrLf & Constants.vbTab & response)
      Me.waitHandle.Set()
    End Sub
  End Class
End Namespace

注釈

サービス コントラクトにコールバック サービス インスタンスが必要な場合は、このコンストラクターを使用します。 ターゲット エンドポイントは、型パラメーターとアプリケーション構成ファイル内の情報から構築されます。

こちらもご覧ください

適用対象

ClientBase<TChannel>(ServiceEndpoint)

ソース:
ClientBase.cs
ソース:
ClientBase.cs
ソース:
ClientBase.cs

指定したClientBase<TChannel>を使用して、ServiceEndpoint クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
protected ClientBase(System.ServiceModel.Description.ServiceEndpoint endpoint);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.Description.ServiceEndpoint -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (endpoint As ServiceEndpoint)

パラメーター

endpoint
ServiceEndpoint

クライアントがサービスを検索して通信できるようにするサービスのエンドポイント。

適用対象

ClientBase<TChannel>(InstanceContext, ServiceEndpoint)

指定したClientBase<TChannel>オブジェクトとInstanceContext オブジェクトを使用して、ServiceEndpoint クラスの新しいインスタンスを初期化します。

protected:
 ClientBase(System::ServiceModel::InstanceContext ^ callbackInstance, System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
protected ClientBase(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Description.ServiceEndpoint endpoint);
new System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)> : System.ServiceModel.InstanceContext * System.ServiceModel.Description.ServiceEndpoint -> System.ServiceModel.ClientBase<'Channel (requires 'Channel : null)>
Protected Sub New (callbackInstance As InstanceContext, endpoint As ServiceEndpoint)

パラメーター

callbackInstance
InstanceContext

接続されたサービスからのメッセージをリッスンするためにクライアント アプリケーションが使用するコールバック オブジェクト。

endpoint
ServiceEndpoint

クライアントがサービスを検索して通信できるようにするサービスのエンドポイント。

適用対象