"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

May 14, 2011

Get Started with WCF

Time to learn WCF (Windows Communication Foundation (WCF)) and basics of it. Basics Explained and References / Examples I tried are provided below

SOA - Service Oriented Architecture. Nutshell - collection of well defined services. Listed below are couple of SOA principles
  • Services must be reusable
  • Services share only contracts and Schema
  • Services are discoverable
  • Services are autonomous - does not depend on any other service
  • Do not expose implementation details
Why WCF ? - Nice Presentation. Covers basics in nutshell
  • Provides below three benefits
  • Interoperability across platforms
  • Unification of existing distributed technology

One Liners
  • Address - Defines where service resides
  • Binding - Define how you can communicate with service
  • Contract - Defines what is done by service
  • Service Contract - Defines what operations client can perform
  • Data Contract - Define what data types are passed (XML Schema Definitions). DataContracts are used to descibe the data types used by a service.
  • Operation Contract - Equivalent to web methods
  • Message Contract - Defines service can directly interact with messages (SOAP Headers). MessageContracts are used to explicitly describe the soap message format.
Basic Example ?
WCF client and WCF service - Steps are clear. Tried this example.
Autogenerated code creates
Iservice.cs
  • Define Interface (Service Contract) - Defines Operation Contract methods in the service contract interface
  • Datacontract class and defines data members
Service1.svc.cs file
  • Implements the service contract (interface). Add definition for methods defined in the service contract
In the console client app to consume service, After adding reference to instantiate provided complete path
ex-
ConsoleApplication2.ServiceReference1.Service1Client client = new ConsoleApplication2.ServiceReference1.Service1Client(); 

Good Reads


WCF in 1 Hour
Windows Communication Foundation: Introduction and Best Practices
How to Host WCF Service in BasicHttpBinding & HTTPS
WCF Data Contracts
How to: Build an N-Tier application with WCF and DataSets in Visual Studio 2008
A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies
Choosing the right WCF binding
WCF and Ria Services. From link
  • RIA Services is something built on top of WCF Services. RIA services connect .NET client objects with .NET server objects using WCF as the underlying communication layer.  
  • RIA Services, unlike plain ADO.NET Data Services, does not automatically generate CRUD at runtime. For people familiar with SQL Server, I describe ADO.NET Data Services as supporting regular triggers (aka query interceptors) while RIA Services requires INSTEAD OF triggers.
  • RIA Services, like ADO.NET Data Services, supports serializing LINQ queries between the client and the server. This means that the client can create the LINQ query and have it run server side
Happy Reading!!

No comments: