语言

ChannelFactory<TChannel> 构造函数

定义

初始化 ChannelFactory<TChannel> 类的新实例。

重载

名称 说明
ChannelFactory<TChannel>()

初始化 ChannelFactory<TChannel> 类的新实例。

ChannelFactory<TChannel>(Binding)

初始化 ChannelFactory<TChannel> 类的新实例。

ChannelFactory<TChannel>(ServiceEndpoint)

初始化生成具有指定终结点的通道的 ChannelFactory<TChannel> 类的新实例。

ChannelFactory<TChannel>(String)

使用指定的终结点配置名称初始化类的新实例 ChannelFactory<TChannel> 。

ChannelFactory<TChannel>(Type)

初始化 ChannelFactory<TChannel> 类的新实例。

ChannelFactory<TChannel>(Binding, EndpointAddress)

使用指定的绑定和终结点地址初始化类的新实例 ChannelFactory<TChannel> 。

ChannelFactory<TChannel>(Binding, String)

使用指定的绑定和远程地址初始化类的新实例 ChannelFactory<TChannel> 。

ChannelFactory<TChannel>(String, EndpointAddress)

初始化与终结点配置和远程地址的指定名称关联的类的新实例 ChannelFactory<TChannel> 。

ChannelFactory<TChannel>()

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

初始化 ChannelFactory<TChannel> 类的新实例。

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

示例

此示例演示如何使用ChannelFactory<TChannel>接口创建类的新对象IRequestChannel。

EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>("MyEndpoint", address);

适用于

ChannelFactory<TChannel>(Binding)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

初始化 ChannelFactory<TChannel> 类的新实例。

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

参数

binding
Binding

为 Binding 工厂生成的通道指定。

注解

如果要以编程方式传递绑定信息而不是使用应用程序配置文件,请使用此构造函数。

适用于

ChannelFactory<TChannel>(ServiceEndpoint)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

初始化生成具有指定终结点的通道的 ChannelFactory<TChannel> 类的新实例。

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

参数

endpoint
ServiceEndpoint

ServiceEndpoint工厂生产的通道。

例外

endpoint 是 null。

示例

ContractDescription contract = new ContractDescription("MyContract");
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
BasicHttpBinding binding = new BasicHttpBinding();
ServiceEndpoint endpoint = new ServiceEndpoint(contract, binding, address);

ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>(endpoint);

注解

如果要以编程方式传递服务终结点信息而不是使用应用程序配置文件,请使用此构造函数。

适用于

ChannelFactory<TChannel>(String)

使用指定的终结点配置名称初始化类的新实例 ChannelFactory<TChannel> 。

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

参数

endpointConfigurationName
String

用于终结点的配置名称。

例外

endpointConfigurationName 是 null。

示例

ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>("MyEndpoint");

注解

当应用程序配置文件中有多个目标终结点时,请使用此构造函数。

适用于

ChannelFactory<TChannel>(Type)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

初始化 ChannelFactory<TChannel> 类的新实例。

protected:
 ChannelFactory(Type ^ channelType);
protected ChannelFactory(Type channelType);
new System.ServiceModel.ChannelFactory<'Channel> : Type -> System.ServiceModel.ChannelFactory<'Channel>
Protected Sub New (channelType As Type)

参数

channelType
Type

Type工厂生产的通道。

例外

channelType 是 null。

channelType是类或值类型,不是接口。

注解

如果要以编程方式传递通道类型信息而不是使用应用程序配置文件,请使用此构造函数。 参数 channelType 必须是接口。

适用于

ChannelFactory<TChannel>(Binding, EndpointAddress)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

使用指定的绑定和终结点地址初始化类的新实例 ChannelFactory<TChannel> 。

public:
 ChannelFactory(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ remoteAddress);
public ChannelFactory(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ChannelFactory<'Channel> : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> System.ServiceModel.ChannelFactory<'Channel>
Public Sub New (binding As Binding, remoteAddress As EndpointAddress)

参数

binding
Binding

Binding用于配置终结点的终结点。

remoteAddress
EndpointAddress

提供 EndpointAddress 服务的位置。

例外

binding 是 null。

示例

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>(binding, address);

注解

如果要以编程方式传递绑定和地址信息,而不是使用应用程序配置文件,请使用此构造函数。

适用于

ChannelFactory<TChannel>(Binding, String)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

使用指定的绑定和远程地址初始化类的新实例 ChannelFactory<TChannel> 。

public:
 ChannelFactory(System::ServiceModel::Channels::Binding ^ binding, System::String ^ remoteAddress);
public ChannelFactory(System.ServiceModel.Channels.Binding binding, string remoteAddress);
new System.ServiceModel.ChannelFactory<'Channel> : System.ServiceModel.Channels.Binding * string -> System.ServiceModel.ChannelFactory<'Channel>
Public Sub New (binding As Binding, remoteAddress As String)

参数

binding
Binding

Binding用于配置终结点的终结点。

remoteAddress
String

提供服务位置的地址。

例外

remoteAddress 是 null。

示例

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
Uri via = new Uri("http://localhost:8000/Via");

ChannelFactory<IRequestChannel> factory =
    new ChannelFactory<IRequestChannel>(binding, "http://fsHost/fs/endp");

IRequestChannel channel = factory.CreateChannel(address, via);
channel.Open();
Message request = Message.CreateMessage(MessageVersion.Soap11, "hello");
Message reply = channel.Request(request);
Console.Out.WriteLine(reply.Headers.Action);
reply.Close();
channel.Close();
factory.Close();

注解

如果要使用字符串而不是类型化对象传递有关远程地址信息的信息,请使用此构造函数。

适用于

ChannelFactory<TChannel>(String, EndpointAddress)

初始化与终结点配置和远程地址的指定名称关联的类的新实例 ChannelFactory<TChannel> 。

public:
 ChannelFactory(System::String ^ endpointConfigurationName, System::ServiceModel::EndpointAddress ^ remoteAddress);
public ChannelFactory(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress);
new System.ServiceModel.ChannelFactory<'Channel> : string * System.ServiceModel.EndpointAddress -> System.ServiceModel.ChannelFactory<'Channel>
Public Sub New (endpointConfigurationName As String, remoteAddress As EndpointAddress)

参数

endpointConfigurationName
String

用于终结点的配置名称。

remoteAddress
EndpointAddress

提供 EndpointAddress 服务的位置。

例外

endpointConfigurationName 或 remoteAddress 为 null.

示例

EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>("MyEndpoint", address);

适用于