开发者

WCF auto-generated proxies Vs custom proxies: which way to go, when and why?

In the last 2 years I've been developing a distributed application in c# 3.5 using WCF at communication tier on TCP/IP protocol; so far I've been using the integrated Add Service Reference... to generate service proxies on the client开发者_运维知识库 side, but I also know that using channel factories to create a communication channel (thus accessing service contract methods) is a viable approach.

The questions are pretty straightforward (please argument the answers):

  • Which are the pros & cons of either approach?
  • Should the "automatic" generation method be preferred in most contexts, and if so, why?
  • Under wich circustances (if any) is the "custom" approach justified/needed?

(please tell me if more contextualization is needed to answer)


For me the one reason to use custom proxies is to be able to use the same interface[type] and domain types on both the client and the server. The automatic generation creates quite a few classes that will inevitably increase the size of your assembly, so if you're building a silverlight app where download time is critical or if you have a hefty memory constraint, channel factory might be the way to go.

I also like the DRY-ness of channel factory, since i typically have my domain objects anyway, why generate them again? Especially if i have a bunch of buisness logic in them. Ofcourse, that is really only applicable to wcf-to-wcf communication, if you're talking to any other service, you'd want to have the domain objects generated

(Im also assuming here that the domain types and interfaces are in their own assembly, separate from the actual back-end persistance code)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜