Implementing Reliability in WCF
WCF uses SOAP reliable messaging to provide end-to-end message transfer reliability between service endpoints in your system, and uses WS-Reliability to provide a layer of reliability between potentially unreliable or intermittently-connected networks. A number of different options are available for defining the specific reliability characteristics you require, such as exactly-once messaging, where a message is guaranteed to be delivered once and once only. Consider the brokerage situation discussed above: If the "sell" message were delivered more than once, you would be oversold and would end up shorting the stock
When using WCF SOAP reliable messaging the reliability provided is end-to-end, regardless of the number of intermediaries between the endpoints. This is very important because most real-world systems will have a number of intermediaries between systems, such as HTTP proxies.
The service you created earlier won't run yet, because its web.config
file isn't properly configured (this is beta software after all). To get the example temperature conversion service used for this article series up and running, you'll need to perform the following steps:
- In your App_Code folder, you'll have a file called Service.cs. Change the code in that file to look like the code below, which defines the temperature conversion service.
// Code for a Temperature Conversion WinFX Service
public interface ITemperatures
double ftoc(double n1);
double ctof(double n1);
public class TemperatureService : ITemperatures
public double ftoc(double f)
double dReturn = 0.0;
dReturn = ((f - 32) * 5) / 9;
public double ctof(double c)
double dReturn = 0.0;
dReturn = ((c + 32) * 9) / 5;
- Next, change your Service.svc file to point to this class. Open the Service.svc file, and change the Class="" attribute to:
This attribute maps the service to the TemperatureService class shown above, which is in the Devx.Indigo.Samples namespace.
- Finally, you'll need to edit your web.config file to initialize the System.ServiceModel that is at the heart of WCF. You can see the web.config that configures the TemperatureServiceClass in the code below.
|Author's Note: If you've been following this series or if you have been working on other samples that use earlier versions of WCF, the schema has changed slightly, so older web.config files are likely to give runtime errors. I've highlighted the parts in bold in the following code where you need to be careful.