Geeks With Blogs
Denis Pitcher Denis Pitcher's Tech Blog

 

The debate has risen of what the best practice is for WCF proxies, should they be generated using Visual Studio references pointing to a WSDL or should they be hand coded and shared alongside service and data contracts through libraries?

Now, admittedly of course using the WSDL option is the instant preference for WCF services that have the potential of facing non .net clients, but what about those who for all intents and purposes will likely forever be consumed by .net clients?

Yavor Georiev from Microsoft suggests on an MSDN forum

You should avoid this if practical in your case, since to maintain interoperability the service and client should only share their contracts in the form of  WSDL, and not the internals of the particular programming language (like classes and interfaces).

However Brian Noyes from IDesign (Colleague of Juval Lowy who wrote the book on WCF) suggests in a presentation on WCF Best Practices:

Hand-code or micro-code generate proxy classes for internal services

  • Less bloated code
  • Share service contract and data contracts through
    libraries
  • Explicit control over config file

Subsequently IDesign’s WCF Coding Standard written by Juval Lowy suggests under section 2. Essentials:

10. When using a tool such as Visual Studio 2008 to generate the proxy, do clean up the proxy.

11. Do not duplicate proxy code.  If two or more clients use the same contract, factor the proxy to a separate class library.

 

So, thus far it seems like the clear best practice is to generate the proxies via the WSDL if you intend to maintain interoperability but be sure to clean them up each time they’re generated.

If interoperability is not a concern then it is an option to share the contracts and proxy through a shared library, especially if more than one client uses the same contract.

Disagree?  Feel welcome to comment and share your sources and reasons as to why.

Posted on Wednesday, September 30, 2009 8:55 PM | Back to top


Comments on this post: WCF Best Practices: Generated of referenced WCF proxies?

No comments posted yet.
Your comment:
 (will show your gravatar)
 


Copyright © Denis Pitcher | Powered by: GeeksWithBlogs.net | Join free