語言

ChannelFactory<TChannel>.CreateChannel 方法

定義

建立指定類型的通道,連接到指定的端點位址。

多載

名稱 Description
CreateChannel(Binding, EndpointAddress, Uri)

建立指定類型的通道,用來向指定傳輸位址的服務端點發送訊息,該位址已設定為指定綁定。

CreateChannel(EndpointAddress, Uri)

建立一個通道,透過指定的傳輸位址向特定端點位址的服務發送訊息。

CreateChannel(Binding, EndpointAddress)

建立指定類型的通道,用來向已設定指定綁定的服務端點發送訊息。

CreateChannel(EndpointAddress)

建立一個通道,用於向特定端點位址的服務發送訊息。

CreateChannel()

建立指定類型的通道,連接到指定的端點位址。

CreateChannel(String)

建立一個通道,用來向端點設定特定方式的服務發送訊息。

備註

建立一個型別 TChannel為 的通道,為類別的一般參數。

CreateChannel(Binding, EndpointAddress, Uri)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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該 that 包含通道傳送訊息的傳輸位址。

傳回

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)

來源:
ChannelFactory.cs
來源:
ChannelFactory.cs
來源:
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該 that 包含通道傳送訊息的傳輸位址。

傳回

TChannel

TChannel由工廠製造的類型IChannel。

實作

例外狀況

address 是 null。

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

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

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

實作

例外狀況

address 是 null。

範例

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

適用於

CreateChannel()

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

建立一個通道,用來向端點設定特定方式的服務發送訊息。

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

適用於