Tuesday, October 28, 2008

WCF Service design guidelines

I followed the following design guidelines for WCF Service with respect of SOA.

1. Service Interface Design [ Service Contract]

Design Service contract that has meaning full operation contract and Indivisible.
Avoid unrelated Operation contracts in the same Service contract.

Include Service operation which has same meaning this is good SOA Practice.
For example in my project a Service Contract defines the following operations like creating, updating, canceling, or inquiring a records.

Use the most efficient messaging pattern for each Service operations
o Request/Reply – Default, even if Operations returns void.

o One-Way -Don’t return a result if there is no use for it. Specify the asynchronous IsOneWay=true setting for an operation if a client does not need to wait for the operation to complete.

o Duplex

Use Data Structure are Contract familiar to the client, do not user System specific data types.[for 100 % interoperability ].

Data contract should be defined and explained which is used in Operation Contract.

2. Service Class Design [ Service Contract Implementation]

Separate Service implementation from Service Interface
Use the same names for both but prefix the service interface with an I.
Make an up-front decision about which instancing model you will use (per call, per session, singleton).[ specify with Service Behavior attribute].
Avoid stateful [Session] service if possible.

Write thread-safe code, so your service can take advantage of multiple-thread concurrency (the default behavior). If it is not possible to write thread-safe code for some reason, be sure to set concurrency mode to single.

Avoid lengthy Service operations that my time out before completed executing

3. Service Hosting

IIS-hosted services provide a number of compelling features, including automatic activation, health monitoring, process recycling, compile-on-demand, and the ability to update the application or its config while still running. IIS also makes it easy to accomplish some things that are hard to do in code, such as supporting SSL. However, IIS also has some limitations. You are limited to the HTTP/S transport (unless using IIS 7.0).



jpenniman said...

The default concurrency mode in WCF is Single, not multiple. If you're running in ServiceHost, and need to be thread-safe, you must explicitly set the concurrency mode to multiple.

aparna john said...

Hi,It’s unbelievable how much better your designs will become when you take into consideration Web Design Cochin four basic principles. There are always more things to consider, but a foundation of contrast, repetition, alignment and proximity will improve your designs dramatically.Thanks........