ChannelFactory<TChannel>.CreateChannel 方法

定义

创建到指定终结点地址的指定类型的通道。

重载

CreateChannel(Binding, EndpointAddress, Uri)

创建一个指定类型的通道,该通道用于将消息发送到用指定绑定配置的指定传输地址处的服务终结点。

CreateChannel(EndpointAddress, Uri)

创建一个通道,该通道用于通过指定的传输地址将消息发送到特定终结点地址的服务。

CreateChannel(Binding, EndpointAddress)

创建一个指定类型的通道,该通道用于将消息发送到用指定绑定进行配置的服务终结点。

CreateChannel(EndpointAddress)

创建用于将消息发送到特定终结点地址的服务的通道。

CreateChannel()

创建到指定终结点地址的指定类型的通道。

CreateChannel(String)

创建一个通道,该通道用于将消息发送到以指定方式配置其终结点的服务。

注解

创建 TChannel 类型(类的泛型参数)的通道。

CreateChannel(Binding, EndpointAddress, Uri)

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

创建一个指定类型的通道,该通道用于将消息发送到用指定绑定配置的指定传输地址处的服务终结点。

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 endpointAddress, Uri via);
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

参数

binding
Binding

用于配置终结点的 Binding

endpointAddress
EndpointAddress

提供服务位置的 EndpointAddress

via
Uri

包含通道向其发送消息的传输地址的 Uri

返回

TChannel

工厂创建的 TChannel 类型的 IChannel

例外

ChannelFactory 有它不支持的双工操作。

示例


 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(EndpointAddress, Uri)

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

创建一个通道,该通道用于通过指定的传输地址将消息发送到特定终结点地址的服务。

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

提供服务位置的 EndpointAddress

via
Uri

包含通道向其发送消息的传输地址的 Uri

返回

TChannel

工厂创建的 TChannel 类型的 IChannel

实现

例外

addressnull

ChannelFactory 有它不支持的双工操作。

示例

    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(Binding, EndpointAddress)

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

创建一个指定类型的通道,该通道用于将消息发送到用指定绑定进行配置的服务终结点。

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 endpointAddress);
static member CreateChannel : System.ServiceModel.Channels.Binding * System.ServiceModel.EndpointAddress -> 'Channel
Public Shared Function CreateChannel (binding As Binding, endpointAddress As EndpointAddress) As TChannel

参数

binding
Binding

用于配置终结点的 Binding

endpointAddress
EndpointAddress

提供服务位置的 EndpointAddress

返回

TChannel

工厂创建的 TChannel 类型的 IChannel

例外

ChannelFactory 有它不支持的双工操作。

示例


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

适用于

CreateChannel(EndpointAddress)

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

创建用于将消息发送到特定终结点地址的服务的通道。

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

提供服务位置的 EndpointAddress

返回

TChannel

工厂创建的 TChannel 类型的 IChannel

实现

例外

addressnull

示例

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

适用于

CreateChannel()

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

创建到指定终结点地址的指定类型的通道。

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

返回

TChannel

工厂创建的 TChannel 类型的 IChannel

示例

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 类型(类的泛型参数)的通道。

适用于

CreateChannel(String)

Source:
ChannelFactory.cs
Source:
ChannelFactory.cs

创建一个通道,该通道用于将消息发送到以指定方式配置其终结点的服务。

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

用于服务的终结点配置的名称。

返回

TChannel

工厂创建的 TChannel 类型的 IChannel

例外

ChannelFactory 有它不支持的双工操作。

示例

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

适用于