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

適用於