简体   繁体   中英

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM