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)

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

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 ()

例外

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

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

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 です。

エンドポイントが見つからないか、エンドポイント コントラクトが有効ではありません。

注釈

このコンストラクターを使用して、ターゲット サービスのコールバック コントラクトを実装するサービス オブジェクトを渡し、アプリケーション構成ファイル内のエンドポイントの名前からターゲット エンドポイント情報を決定します (ターゲット値は、クライアント <エンドポイント>要素の属性を見つけること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.cs
ソース:
ClientBase.cs

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 です。

エンドポイントが見つからないか、エンドポイント コントラクトが有効ではありません。

注釈

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

こちらもご覧ください

適用対象

ClientBase<TChannel>(String, EndpointAddress)

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

指定したターゲット アドレスとエンドポイント情報を使用して、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 です。

エンドポイントが見つからないか、エンドポイント コントラクトが有効ではありません。

注釈

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

エンドポイントが見つからないか、エンドポイント コントラクトが有効ではありません。

注釈

このコンストラクターを使用して、ターゲットのサービスのコールバック コントラクトを実装するサービス オブジェクトを渡し、クライアント アプリケーション構成ファイルからのターゲット エンドポイント情報を特定します。 ターゲット値は、クライアント <エンドポイント>要素の属性を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 です。

エンドポイントが見つからないか、エンドポイント コントラクトが有効ではありません。

注釈

このコンストラクターを使用して、ターゲット サービスのコールバック コントラクトを実装するサービス オブジェクトを渡し、アプリケーション構成ファイル内のエンドポイントの名前からターゲット エンドポイント情報を決定します (ターゲット値は、クライアント <エンドポイント>要素の属性を見つけること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.cs
ソース:
ClientBase.cs

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 です。

エンドポイントが見つからないか、エンドポイント コントラクトが有効ではありません。

注釈

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

適用対象

ClientBase<TChannel>(InstanceContext)

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

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

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

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

適用対象