語言

ChannelFactory<TChannel> 建構函式

定義

初始化 ChannelFactory<TChannel> 類別的新執行個體。

多載

名稱 Description
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>()

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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);

適用於