Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News David Pallmann’s WCF Tips

David Pallmann’s WCF Tips

David Pallmann has published a series of WCF Tips. The tips are assembled in terms of design patterns, which are grouped by aspects of developing WCF providers and consumers.

The series discusses the following aspects:

  1. Service Interface Design
  2. Service Class Design
  3. Service Hosting
  4. Configuration
  5. Infrastructure
  6. Instrumentation
  7. Clients

Concerning service interfaces Dave advices that all operations of a single service interface should share a common theme, should be coarse-grained and prefer asynchronous messaging. Service metadata, at least WSDLs and XSDs, should be registered within a service catalog/registry. Document or data structures should address the consumer's needs instead of representing internals of a service. This advice goes in line with Pat Helland's "Data on the Outside vs. Data on the inside".

Keep service interface and service implementation apart from each other and be very explicit about your implementation choices, especially the instancing model. Avoid stateful services and write thread-safe code.

Choose your service host according to your needs, not in favour of your likings or the model, which is familiar to you. In any case don't rely on the default settings, which are not appropriate for real-world scenarios:

Learn the appropriate knobs to turn to make WCF perform for you. Don’t assume the defaults are best, in many cases they aren’t. [...] Some of the default settings in WCF are great. Some of them aren’t. Some of them, in the name of being secure out-of-box, prevent you performing useful work!

Although any SOA should be driven by business needs, you have to choose the right infrastructure in order to accommodate your non-functional requirements. The main topics of infrastructure services are loose-coupling and discovery of services. Some examples of infrastructure or technical services are:

  • Directory of services
  • Message router
  • Message transformation
  • Rules service
  • Workflow host
  • Integration adapter
  • Activity monitor

Remember to enable instrumentation of WCF services by configuring services to publish metadata and report status information. The first is accomplished by publishing a WS-MetadataExchange endpoint and the latter by enabling Windows Management Instrumentation (WMI) within your service configuration.

Finally David points out that you shouldn't rely on generated proxy clients. The default generation does not implement error handling, which is essential for robust client code.

This assortments of tips is by no means complete, but it offers a good starting point and a minimal checklist for WCF service development. Seemingly the most important points are service configuration and service discovery. Useful discovery services are missing and metadata publishing is disabled by default. The configuration defaults are not appropriate for a real-world context, they have rather been chosen "in the name of shipping 'securely by default'".

Rate this Article