I am confused about the Proxy and Channels. According to my reading, WCF client is using a proxy which pass the message through a chain of channels. Every Channel is responsible of certain task, for example one channel is encoding the message and another Channel is encrypting it.
My confusion begins when I saw the following code
When proxy.MyMethod()
is called, it actually called the whole chain of channels?
The author used method called CreateChannel
and named the identifier proxy. So in WCF architecture Proxy is just a spacial high level channel, it is not a stand alone architecture element?
Binding binding = new NetTcpBinding();
EndpointAddress address = new EndpointAddress("net.tcp://localhost:8000");
IMyContract proxy = ChannelFactory<IMyContract>.CreateChannel(binding,address);
using(proxy as IDisposable)
{
proxy.MyMethod();
}
In WCF you have 3 main component - Contract, Adress and Binding. The channel is a pipe, which is building according to these three parts.
The aim of the channel is to modify the message into format, that is understood for both - client and server, and to organize it's proper transport. The transport and protocol channels are used for this. To make this process easier, we use bindings. Each binding consists of elements, which are representing some channel in channel stack.
So, each time when you call you method, it forms the message according to your DataContract, and passes it throught the whole chain of channels. Each channel modifies your message. The prosses looks like this
A WCF proxy is really just a level of abstraction. It is an in-process representative of an out-of-process service. You can imagine it as an object, generated and properly configured according to your binding elements and your dataContract, which allows your client-side and server-side to understand each other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With