Service Orientation and WCF






2.10/5 (9 votes)
Aug 17, 2006
2 min read

22897
An article about service orientation in Windows communication foundation
Title: Service Orientation and WCF Author: Bibin Isac Mohan Email: Bibin.mohan@yahoo.com Environment: WinFx Keywords: WCF Level: Beginner" Description: An article about service orientation in Windows communication foundation Section Miscellaneous SubSection General
Introduction
WCF is based on the principles of service orientation through message exchanges. Services are functionalities provided to the consumers. Here basically we provide services, rather than Methods or Classes. Service orientation is a way of thinking, not a way of implementation, not dependent on any platform. Services are built to last, thr availability and stability are critical.
Background
Service orientation is based on its 4 fundamental tenets.
- Boundaries are explicit – A boundary represents the border between a service’s public interface and its internal public implementation. In case of ASP.net web service, a services boundary is published through WSDL. Services are defined in a way that its internal implementation details are not exposed through any interface. Each service interaction deals with boundary crossing. Because each
- cross-boundary communication is potentially costly, service-orientation is based on a model of explicit message passing rather than implicit method invocation.
- Services are autonomous - Individual services are always deployed, versioned, and managed independently. To maintain system integrity, service-oriented designs use techniques such as transactions, durable queues, redundant deployment and failover.
- Services share schema and contract, not class - Services interact based solely on schemas (for structures) and contracts (for behaviors). This strict separation between structure and behavior vastly simplifies deployment. Unlike object oriented classes, services do not conflate structure and behavior.
- Service compatibility is determined based on policy - The WS-Policy specification defines a machine-readable policy framework capable of expressing service-level policies, enabling them to be discovered or enforced at execution time. Policy expressions indicate which conditions and guarantees (called assertions) must hold true to enable the normal operation of the service.
Programming service in WCF
using System; using System.Collections.Generic; using System.Text; using System.ServiceModel; namespace WCF_BasicService { // This is the functional specification contract [ServiceContract()] public interface IBasicService { [OperationContract(IsOneWay = false)] string GreetUser(string strUsername); } // And this is the functional specification implementation internal class BasicService : IBasicService { public string GreetUser(string strUsername) { return "Hello " + strUsername; } } class Program { static void Main(string[] args) { Uri urlService = new Uri("http://localhost:1979/2006"); ServiceHost host = new ServiceHost(typeof(BasicService), urlService); // Add "plugin" to speak to SOAP clients BasicHttpBinding bhb = new BasicHttpBinding(BasicHttpSecurityMode.None); host.AddServiceEndpoint(typeof(IBasicService), bhb, "WCF_BasicService_SOAP"); // Add "plugin" to speak to TCP clients NetTcpBinding tcp = new NetTcpBinding(System.ServiceModel.Channels.SecurityMode.None); host.AddServiceEndpoint(typeof(IBasicService), tcp, "net.tcp://localhost/2006/WCF_BasicService_TCP"); host.Open(); Console.WriteLine("WCF_BasicService is running. Press ENTER to shutdown."); Console.ReadLine(); host.Close(); host.Dispose(); } } }
History
:-) I am done with the first version. </body> </html>