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

例外

endpointnull

示例

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)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

使用指定的终结点配置名称初始化 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

用于终结点的配置名称。

例外

endpointConfigurationNamenull

示例

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

例外

channelTypenull

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

例外

bindingnull

示例

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

提供服务位置的地址。

例外

remoteAddressnull

示例

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)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

初始化 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

例外

endpointConfigurationNameremoteAddressnull

示例

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

适用于