September 25
WCF Tips #7 - Clients
David Pallmann’s WCF Tips #7 - Clients
Tip: Don’t use generated proxy clients, which make no provision for recovering from errors. Use robust client code that retries failed communications on time-out and re-created proxies on communication failures.
Rationale: Generating a WCF client from metadata is easy and gets you started quickly. Unfortunately, this code does not handle errors. In real-world solutions, WCF clients need to do the following:
· Retry on minor failures: A minor failure such as a time-out should not abort processing; a limited number of retries is in order before giving up on an access. Code a small (and configurable) retry count and re-issue invocations after minor failures.
· Recreate proxy on major failures: A major failure such as a faulted communication object should result in re-creation of the proxy to the service, then a retry as described above.