ChannelFactory<TChannel>.CreateChannel 方法

定義

建立指向指定之端點位址的指定型別通道。Creates a channel of a specified type to a specified endpoint address.

多載

CreateChannel(Binding, EndpointAddress, Uri)

建立用來傳送訊息至服務端點之指定型別的通道,在指定傳輸位址的此服務端點採用指定的繫結設定。Creates a channel of a specified type that is used to send messages to a service endpoint at a specified transport address that is configured with a specified binding.

CreateChannel(Binding, EndpointAddress)

建立用來傳送訊息至服務端點之指定型別的通道,此服務端點採用指定的繫結設定。Creates a channel of a specified type that is used to send messages to a service endpoint that is configured with a specified binding.

CreateChannel(EndpointAddress, Uri)

建立一個透過指定傳輸位址將訊息傳送至指定端點位址的服務的通道。Creates a channel that is used to send messages to a service at a specific endpoint address through a specified transport address.

CreateChannel(EndpointAddress)

建立用來傳送訊息至指定端點位址的服務的通道。Creates a channel that is used to send messages to a service at a specific endpoint address.

CreateChannel()

建立指向指定之端點位址的指定型別通道。Creates a channel of a specified type to a specified endpoint address.

CreateChannel(String)

建立用來傳送訊息至指定端點位址的服務的通道,此服務的端點採用特定方式設定。Creates a channel that is used to send messages to a service whose endpoint is configured in a specified way.

備註

建立 TChannel 型別的通道 (類別的泛型參數)。Creates a channel of type TChannel, the generic parameter for the class.

CreateChannel(Binding, EndpointAddress, Uri)

建立用來傳送訊息至服務端點之指定型別的通道,在指定傳輸位址的此服務端點採用指定的繫結設定。Creates a channel of a specified type that is used to send messages to a service endpoint at a specified transport address that is configured with a specified binding.

public:
 static TChannel CreateChannel(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ endpointAddress, Uri ^ via);
public:
 static TChannel CreateChannel(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ address, Uri ^ via);
public static TChannel CreateChannel (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress endpointAddress, Uri via);
public static TChannel CreateChannel (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress address, Uri via);
static member CreateChannel : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress * Uri -> 'Channel
static member CreateChannel : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress * Uri -> 'Channel
Public Shared Function CreateChannel (binding As Binding, endpointAddress As EndpointAddress, via As Uri) As TChannel
Public Shared Function CreateChannel (binding As Binding, address As EndpointAddress, via As Uri) As TChannel

參數

binding
Binding

用於設定端點的 BindingThe Binding used to configure the endpoint.

endpointAddressaddress
EndpointAddress

提供服務位置的 EndpointAddressThe EndpointAddress that provides the location of the service.

via
Uri

包含通道傳送訊息之目標傳輸位址的 UriThe Uri that contains the transport address to which the channel sends messages.

傳回

TChannel

由處理站所建立之 TChannel 型別的 IChannelThe TChannel of type IChannel created by the factory.

例外狀況

ChannelFactory 有其不支援的雙工操作。The ChannelFactory has duplex operations it does not support.

範例


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

 IRequestChannel channel =
ChannelFactory<IRequestChannel>.CreateChannel(binding, address, uri);
 channel.Open();
class Program : ChannelFactory<IService1Channel>
{
    static void Main(string[] args)
    {
        IService1Channel channel = CreateChannel("BasicHttpBinding_IService1");
        channel.Open();

        channel.Close();
    }
}

適用於

CreateChannel(Binding, EndpointAddress)

建立用來傳送訊息至服務端點之指定型別的通道,此服務端點採用指定的繫結設定。Creates a channel of a specified type that is used to send messages to a service endpoint that is configured with a specified binding.

public:
 static TChannel CreateChannel(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ endpointAddress);
public:
 static TChannel CreateChannel(System::ServiceModel::Channels::Binding ^ binding, System::ServiceModel::EndpointAddress ^ address);
public static TChannel CreateChannel (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress endpointAddress);
public static TChannel CreateChannel (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress address);
static member CreateChannel : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> 'Channel
static member CreateChannel : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> 'Channel
Public Shared Function CreateChannel (binding As Binding, endpointAddress As EndpointAddress) As TChannel
Public Shared Function CreateChannel (binding As Binding, address As EndpointAddress) As TChannel

參數

binding
Binding

用於設定端點的 BindingThe Binding used to configure the endpoint.

endpointAddressaddress
EndpointAddress

提供服務位置的 EndpointAddressThe EndpointAddress that provides the location of the service.

傳回

TChannel

由處理站所建立之 TChannel 型別的 IChannelThe TChannel of type IChannel created by the factory.

例外狀況

ChannelFactory 有其不支援的雙工操作。The ChannelFactory has duplex operations it does not support.

範例


       EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
       IRequestChannel channel = ChannelFactory<IRequestChannel>.CreateChannel(binding, address);
       channel.Open();

適用於

CreateChannel(EndpointAddress, Uri)

建立一個透過指定傳輸位址將訊息傳送至指定端點位址的服務的通道。Creates a channel that is used to send messages to a service at a specific endpoint address through a specified transport address.

public:
 virtual TChannel CreateChannel(System::ServiceModel::EndpointAddress ^ address, Uri ^ via);
public virtual TChannel CreateChannel (System.ServiceModel.EndpointAddress address, Uri via);
abstract member CreateChannel : System.ServiceModel.EndpointAddress * Uri -> 'Channel
override this.CreateChannel : System.ServiceModel.EndpointAddress * Uri -> 'Channel
Public Overridable Function CreateChannel (address As EndpointAddress, via As Uri) As TChannel

參數

address
EndpointAddress

提供服務位置的 EndpointAddressThe EndpointAddress that provides the location of the service.

via
Uri

包含通道傳送訊息之目標傳輸位址的 UriThe Uri that contains the transport address to which the channel sends messages.

傳回

TChannel

由處理站所建立之 TChannel 型別的 IChannelThe TChannel of type IChannel created by the factory.

實作

例外狀況

addressnulladdress is null.

ChannelFactory 有其不支援的雙工操作。The ChannelFactory has duplex operations it does not support.

範例

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

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

適用於

CreateChannel(EndpointAddress)

建立用來傳送訊息至指定端點位址的服務的通道。Creates a channel that is used to send messages to a service at a specific endpoint address.

public:
 virtual TChannel CreateChannel(System::ServiceModel::EndpointAddress ^ address);
public TChannel CreateChannel (System.ServiceModel.EndpointAddress address);
abstract member CreateChannel : System.ServiceModel.EndpointAddress -> 'Channel
override this.CreateChannel : System.ServiceModel.EndpointAddress -> 'Channel
Public Function CreateChannel (address As EndpointAddress) As TChannel

參數

address
EndpointAddress

提供服務位置的 EndpointAddressThe EndpointAddress that provides the location of the service.

傳回

TChannel

由處理站所建立之 TChannel 型別的 IChannelThe TChannel of type IChannel created by the factory.

實作

例外狀況

addressnulladdress is null.

範例

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

適用於

CreateChannel()

建立指向指定之端點位址的指定型別通道。Creates a channel of a specified type to a specified endpoint address.

public:
 TChannel CreateChannel();
public TChannel CreateChannel ();
member this.CreateChannel : unit -> 'Channel
Public Function CreateChannel () As TChannel

傳回

TChannel

由處理站所建立之 TChannel 型別的 IChannelThe TChannel of type IChannel created by the factory.

範例

IChannelFactory<IRequestChannel> factory = binding.BuildChannelFactory<IRequestChannel>(bindingParams);
factory.Open();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
IRequestChannel channel = factory.CreateChannel(address);
channel.Open();

備註

建立 TChannel 型別的通道 (類別的泛型參數)。Creates a channel of type TChannel, the generic parameter for the class.

適用於

CreateChannel(String)

建立用來傳送訊息至指定端點位址的服務的通道,此服務的端點採用特定方式設定。Creates a channel that is used to send messages to a service whose endpoint is configured in a specified way.

protected:
 static TChannel CreateChannel(System::String ^ endpointConfigurationName);
protected static TChannel CreateChannel (string endpointConfigurationName);
static member CreateChannel : string -> 'Channel
Protected Shared Function CreateChannel (endpointConfigurationName As String) As TChannel

參數

endpointConfigurationName
String

該服務所用的端點組態名稱。The name of the endpoint configuration used for the service.

傳回

TChannel

由處理站所建立之 TChannel 型別的 IChannelThe TChannel of type IChannel created by the factory.

例外狀況

ChannelFactory 有其不支援的雙工操作。The ChannelFactory has duplex operations it does not support.

範例

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

    ChannelFactory<IRequestChannel> factory =
        new ChannelFactory<IRequestChannel>(binding, address);

    IRequestChannel channel = factory.CreateChannel();
    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();
}	

適用於