Share via


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

定義

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

オーバーロード

WebChannelFactory<TChannel>()

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

WebChannelFactory<TChannel>(Binding)

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

WebChannelFactory<TChannel>(ServiceEndpoint)

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

WebChannelFactory<TChannel>(String)

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

WebChannelFactory<TChannel>(Type)

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

WebChannelFactory<TChannel>(Uri)

WebChannelFactory<TChannel> を指定して、Uri クラスの新しいインスタンスを初期化します。

WebChannelFactory<TChannel>(Binding, Uri)

指定したバインドと WebChannelFactory<TChannel> を使用して Uri クラスの新しいインスタンスを初期化します。

WebChannelFactory<TChannel>(String, Uri)

指定したエンドポイント構成と WebChannelFactory<TChannel> を使用して Uri クラスの新しいインスタンスを初期化します。

WebChannelFactory<TChannel>()

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

public:
 WebChannelFactory();
public WebChannelFactory ();
Public Sub New ()

適用対象

WebChannelFactory<TChannel>(Binding)

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

public:
 WebChannelFactory(System::ServiceModel::Channels::Binding ^ binding);
public WebChannelFactory (System.ServiceModel.Channels.Binding binding);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : System.ServiceModel.Channels.Binding -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (binding As Binding)

パラメーター

binding
Binding

チャネルを作成するときに使用するバインド。

次のコードは、このコンストラクターを使用して を WebChannelFactory<TChannel> 作成し、それを使用して WCF サービスを呼び出す方法を示しています。

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();
    WebHttpBinding binding = new WebHttpBinding();
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(binding);
    cf.Endpoint.Address = new EndpointAddress("http://localhost:8000");
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()
    Dim binding As New WebHttpBinding()
    Dim cf As New WebChannelFactory(Of IService)(binding)
    cf.Endpoint.Address = New EndpointAddress("http://localhost:8000")
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

適用対象

WebChannelFactory<TChannel>(ServiceEndpoint)

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

public:
 WebChannelFactory(System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
public WebChannelFactory (System.ServiceModel.Description.ServiceEndpoint endpoint);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : System.ServiceModel.Description.ServiceEndpoint -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (endpoint As ServiceEndpoint)

パラメーター

endpoint
ServiceEndpoint

チャネルを作成するときに使用するエンドポイント。

次のコードは、このコンストラクターを使用して を WebChannelFactory<TChannel> 作成し、それを使用して WCF サービスを呼び出す方法を示しています。

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    WebHttpBinding binding = new WebHttpBinding();
    ContractDescription desc = ContractDescription.GetContract(typeof(IService));
    EndpointAddress endpointAddress = new EndpointAddress("http://localhost:8000");
    ServiceEndpoint endpoint = new ServiceEndpoint(desc, binding, endpointAddress);

    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(endpoint);
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    Dim binding As New WebHttpBinding()
    Dim desc As ContractDescription = ContractDescription.GetContract(GetType(IService))
    Dim endpointAddress As New EndpointAddress("http://localhost:8000")
    Dim endpoint As New ServiceEndpoint(desc, binding, endpointAddress)

    Dim cf As New WebChannelFactory(Of IService)(endpoint)
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

適用対象

WebChannelFactory<TChannel>(String)

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

public:
 WebChannelFactory(System::String ^ endpointConfigurationName);
public WebChannelFactory (string endpointConfigurationName);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : string -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (endpointConfigurationName As String)

パラメーター

endpointConfigurationName
String

チャネルが構成されるアプリケーション構成ファイル内の名前。

次のコードは、このコンストラクターを使用してインスタンスを WebChannelFactory<TChannel> 作成し、それを使用して WCF サービスを呼び出す方法を示しています。

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    // The endpoint name passed to the constructor must match an endpoint element
    // in the application configuration file
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>("MyEndpoint");
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    ' The endpoint name passed to the constructor must match an endpoint element
    ' in the application configuration file
    Dim cf As New WebChannelFactory(Of IService)("MyEndpoint")
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

注釈

endpointConfigurationName パラメーターは、アプリケーション構成ファイルのname 要素の <endpoint> 属性と同じ値に設定する必要があります。

適用対象

WebChannelFactory<TChannel>(Type)

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

public:
 WebChannelFactory(Type ^ channelType);
public WebChannelFactory (Type channelType);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : Type -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (channelType As Type)

パラメーター

channelType
Type

使用するチャネルの型。

注釈

型パラメーターについて渡される型はインターフェイスである必要があります。

適用対象

WebChannelFactory<TChannel>(Uri)

WebChannelFactory<TChannel> を指定して、Uri クラスの新しいインスタンスを初期化します。

public:
 WebChannelFactory(Uri ^ remoteAddress);
public WebChannelFactory (Uri remoteAddress);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : Uri -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (remoteAddress As Uri)

パラメーター

remoteAddress
Uri

呼び出される Web サービスの URI。

このコンストラクターを使用して WebChannelFactory<TChannel> インスタンスを作成し、サービスを呼び出す方法を次のコードに示します。

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(new Uri("http://localhost:8000"));
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    Dim cf As New WebChannelFactory(Of IService)(New Uri("http://localhost:8000"))
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

適用対象

WebChannelFactory<TChannel>(Binding, Uri)

指定したバインドと WebChannelFactory<TChannel> を使用して Uri クラスの新しいインスタンスを初期化します。

public:
 WebChannelFactory(System::ServiceModel::Channels::Binding ^ binding, Uri ^ remoteAddress);
public WebChannelFactory (System.ServiceModel.Channels.Binding binding, Uri remoteAddress);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : System.ServiceModel.Channels.Binding * Uri -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (binding As Binding, remoteAddress As Uri)

パラメーター

binding
Binding

使用するバインド。

remoteAddress
Uri

呼び出される Web サービスの URI。

このコンストラクターを使用して WebChannelFactory<TChannel> インスタンスを作成し、サービスを呼び出す方法を次のコードに示します。

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    WebHttpBinding binding = new WebHttpBinding();
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(binding, new Uri("http://localhost:8000"));
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    Dim binding As New WebHttpBinding()
    Dim cf As New WebChannelFactory(Of IService)(binding, New Uri("http://localhost:8000"))
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

適用対象

WebChannelFactory<TChannel>(String, Uri)

指定したエンドポイント構成と WebChannelFactory<TChannel> を使用して Uri クラスの新しいインスタンスを初期化します。

public:
 WebChannelFactory(System::String ^ endpointConfigurationName, Uri ^ remoteAddress);
public WebChannelFactory (string endpointConfigurationName, Uri remoteAddress);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : string * Uri -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (endpointConfigurationName As String, remoteAddress As Uri)

パラメーター

endpointConfigurationName
String

チャネルが構成されるアプリケーション構成ファイル内の名前。

remoteAddress
Uri

呼び出される Web サービスの URI。

このコンストラクターを使用して WebChannelFactory<TChannel> インスタンスを作成し、サービスを呼び出す方法を次のコードに示します。

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    // The endpoint name passed to the constructor must match an endpoint element
    // in the application configuration file
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>("MyEndpoint", new Uri("http://localhost:8000"));
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    ' The endpoint name passed to the constructor must match an endpoint element
    ' in the application configuration file
    Dim cf As New WebChannelFactory(Of IService)("MyEndpoint", New Uri("http://localhost:8000"))
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

注釈

endpointConfigurationName パラメーターは、アプリケーション構成ファイルのname 要素の <endpoint> 属性と同じ値に設定する必要があります。

適用対象