Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Windows Communication Foundation: Service Reliability is the Key : Page 2

Sending messages has become easy and commonplace, but making sure messages are received has been more difficult—until now. Find out how to configure your Windows Communication Foundation applications to add guaranteed message delivery between systems and networks.


advertisement
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:

  1. 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.
  2. // Code for a Temperature Conversion WinFX Service using System; using System.ServiceModel; namespace Devx.Indigo.Samples { [ServiceContract()] public interface ITemperatures { [OperationContract] double ftoc(double n1); [OperationContract] double ctof(double n1); } public class TemperatureService : ITemperatures { public double ftoc(double f) { double dReturn = 0.0; dReturn = ((f - 32) * 5) / 9; return dReturn; } public double ctof(double c) { double dReturn = 0.0; dReturn = ((c + 32) * 9) / 5; return dReturn; } } }

  3. Next, change your Service.svc file to point to this class. Open the Service.svc file, and change the Class="" attribute to:
  4. Class="Devx.Indigo.Samples.TemperatureService"

    This attribute maps the service to the TemperatureService class shown above, which is in the Devx.Indigo.Samples namespace.

  5. 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.



<?xml version="1.0"?> <configuration xmlns= "http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.serviceModel> <services> <service behaviorConfiguration= "TemperatureServiceBehavior" type="Devx.Indigo.Samples.TemperatureService"> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1" contract= "Devx.Indigo.Samples.ITemperatures"/> </service> </services> <behaviors> <behavior name="TemperatureServiceBehavior" returnUnknownExceptionsAsFaults="True"> </behavior> </behaviors> <bindings> <wsHttpBinding> <binding name="Binding1"/> </wsHttpBinding> </bindings> </system.serviceModel> <system.web> <compilation debug="true"/> </system.web> </configuration>




Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap