ChannelFactory<TChannel> Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the ChannelFactory<TChannel> class.
Overloads
ChannelFactory<TChannel>() |
Initializes a new instance of the ChannelFactory<TChannel> class. |
ChannelFactory<TChannel>(Binding) |
Initializes a new instance of the ChannelFactory<TChannel> class. |
ChannelFactory<TChannel>(ServiceEndpoint) |
Initializes a new instance of the ChannelFactory<TChannel> class that produces channels with a specified endpoint. |
ChannelFactory<TChannel>(String) |
Initializes a new instance of the ChannelFactory<TChannel> class with a specified endpoint configuration name. |
ChannelFactory<TChannel>(Type) |
Initializes a new instance of the ChannelFactory<TChannel> class. |
ChannelFactory<TChannel>(Binding, EndpointAddress) |
Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and endpoint address. |
ChannelFactory<TChannel>(Binding, String) |
Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and remote address. |
ChannelFactory<TChannel>(String, EndpointAddress) |
Initializes a new instance of the ChannelFactory<TChannel> class associated with a specified name for the endpoint configuration and remote address. |
ChannelFactory<TChannel>()
- Source:
- ChannelFactory.cs
- Source:
- ChannelFactory.cs
Initializes a new instance of the ChannelFactory<TChannel> class.
public:
ChannelFactory();
public ChannelFactory ();
Public Sub New ()
Examples
This example shows how to create a new object of the ChannelFactory<TChannel> class with the IRequestChannel
interface.
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>("MyEndpoint", address);
Applies to
ChannelFactory<TChannel>(Binding)
- Source:
- ChannelFactory.cs
- Source:
- ChannelFactory.cs
Initializes a new instance of the ChannelFactory<TChannel> class.
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)
Parameters
Remarks
Use this constructor when you want to pass the binding information programmatically rather than using an application configuration file.
Applies to
ChannelFactory<TChannel>(ServiceEndpoint)
- Source:
- ChannelFactory.cs
- Source:
- ChannelFactory.cs
Initializes a new instance of the ChannelFactory<TChannel> class that produces channels with a specified endpoint.
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)
Parameters
- endpoint
- ServiceEndpoint
The ServiceEndpoint for the channels produced by the factory.
Exceptions
The endpoint
is null
.
Examples
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);
Remarks
Use this constructor when you want to pass the service endpoint information programmatically rather than using an application configuration file.
Applies to
ChannelFactory<TChannel>(String)
Initializes a new instance of the ChannelFactory<TChannel> class with a specified endpoint configuration name.
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)
Parameters
- endpointConfigurationName
- String
The configuration name used for the endpoint.
Exceptions
endpointConfigurationName
is null
.
Examples
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>("MyEndpoint");
Remarks
Use this constructor when there is more than one target endpoint in the application configuration file.
Applies to
ChannelFactory<TChannel>(Type)
- Source:
- ChannelFactory.cs
- Source:
- ChannelFactory.cs
Initializes a new instance of the ChannelFactory<TChannel> class.
protected:
ChannelFactory(Type ^ channelType);
protected ChannelFactory (Type channelType);
new System.ServiceModel.ChannelFactory<'Channel> : Type -> System.ServiceModel.ChannelFactory<'Channel>
Protected Sub New (channelType As Type)
Parameters
Exceptions
The channelType
is null
.
The channelType
is a class or value type and is not an interface.
Remarks
Use this constructor when you want to pass the channel type information programmatically rather than using an application configuration file. The channelType
parameter must be an interface.
Applies to
ChannelFactory<TChannel>(Binding, EndpointAddress)
- Source:
- ChannelFactory.cs
- Source:
- ChannelFactory.cs
Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and endpoint address.
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)
Parameters
- remoteAddress
- EndpointAddress
The EndpointAddress that provides the location of the service.
Exceptions
The binding
is null
.
Examples
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>(binding, address);
Remarks
Use this constructor when you want to pass the binding and address information programmatically rather than using an application configuration file.
Applies to
ChannelFactory<TChannel>(Binding, String)
- Source:
- ChannelFactory.cs
- Source:
- ChannelFactory.cs
Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and remote address.
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)
Parameters
- remoteAddress
- String
The address that provides the location of the service.
Exceptions
remoteAddress
is null
.
Examples
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();
Remarks
Use this constructor when you want to pass the information about the remote address information with a string rather than as a typed object.
Applies to
ChannelFactory<TChannel>(String, EndpointAddress)
Initializes a new instance of the ChannelFactory<TChannel> class associated with a specified name for the endpoint configuration and remote address.
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)
Parameters
- endpointConfigurationName
- String
The configuration name used for the endpoint.
- remoteAddress
- EndpointAddress
The EndpointAddress that provides the location of the service.
Exceptions
endpointConfigurationName
or remoteAddress
is null
.
Examples
EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>("MyEndpoint", address);