Essentials
Place service code in a class library and not in any hosting EXE.
Do not provide parameterized constructors to a service class unless it is a singleton that is hosted explicitly.
Enable reliability in the relevant bindings.
Provide a meaningful namespace for contracts. For outward-facing services, use your company’s URL or equivalent URN with a year and month to support versioning; for example:
[ServiceContract(Namespace = "http://www.idesign.net/2007/08")] interface IMyContract {...}For intranet services, use any meaningful unique name, such as
MyApplication; for example:[ServiceContract(Namespace = "MyApplication")] interface IMyContract {...}With intranet applications on Windows XP and Windows Server 2003, prefer self-hosting to IIS hosting.
On Windows Vista, prefer WAS (IIS7) hosting to self-hosting.
Use
ServiceHost<T>.Enable metadata exchange.
Always name all endpoints in the client config file.
Do not use SvcUtil or Visual Studio 2005 to generate a config file.
Do not duplicate proxy code. If two or more clients use the same contract, factor the proxy to a separate class library.
Always close or dispose of the proxy.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access