开发者

Channel Factory Class - WCF

May I Know the use of channelfactory clas开发者_运维技巧s in WCF. Does it help us to prevent updating the service reference manually if there is any code change in the service ?


It's part of the process of building a client side proxy to call your service.

By default, if you do a "Add Service Reference", you just get a (myService)Client class which you can instantiate and use.

What this does behind the scenes is a two-step process:

  • create a channel factory for your service contract (ChannelFactory<T>) - this is a class that has the ability to create a contract-specific channel (a communications link between your client and the service being called)

  • then actually creating a channel using that channel factory, to establish the link.

Creating the channel factory is a fairly expensive step - so if you do it manually, you'd want to try and cache that channel factory for as long as you can.

Creating the actual channel from the channel factory is not nearly as intensive a task.

So if you do have access to your service contract (e.g. by means of a shared contracts assmebly), you can break up the process of creating your client side proxy into two steps, and hopefully optimize the first one (by caching the channel factory).

But again: this requires you have access to your service contract directly - typically only the case if you control both ends of the communication, and both ends are .NET.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜