ChannelFactory<TChannel> Constructor (Binding^, String^)

 

Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and remote address.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public:
ChannelFactory(
	Binding^ binding,
	String^ remoteAddress
)

Parameters

binding
Type: System.ServiceModel.Channels::Binding^

The Binding used to configure the endpoint.

remoteAddress
Type: System::String^

The address that provides the location of the service.

Exception Condition
ArgumentNullException

remoteAddress is null.

Use this constructor when you want to pass the information about the remote address information with a string rather than as a typed object.

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

.NET Framework
Available since 3.0
Return to top
Show: