Getting Started with Adobe After Effects - Part 6: Motion Blur

Upload Image Close it
Select File

Dinesh's Blog
Browse by Tags · View All
brh 20
silverlight 18
Silverlight 4.0 9
bing 7
bing maps 6
wcf services 5
map 5

Archive · View All
August 2010 10
September 2010 3
July 2010 3
June 2010 3
October 2010 1

Introduction to WCF Service

Jul 11 2010 3:22PM by Dinesh Sodani   

In my previous post I described how to add multiple pushpins on Bing Map by fetching data from XML data source. In this post I will explain some basics of WCF Services to add multiple pushpins on Bing Map by fetching data from SQL Server Database.

We cannot access SQL Server directly from Silverlight. There needs to be a layer in between Silverlight and the SQL Server. You need to use

There are many resources available for WCF Services over the internet. Here I would like to describe basic concepts related with WCF required to achieve our main goal.

What is WCF

Windows Communication Foundation (WCF) is a part of the .NET Framework that provides a unified programming model for rapidly building service-oriented applications that communicate across the web and the enterprise.

WCF comes up as a replacement for Remoting and Web service in donet.

Web Services:

  1. It can be accesses only over HTTP.
  2. It works in stateless environment.
  3. It supports only the data types defined in the XSD type system, limiting the number of objects that can be serialized.
  4. It support interoperability across platforms, and are ideal for heterogeneous environments.

.Net Remoting:

  1. It can be accessed over any protocol
  2. Provide support for both stateful and stateless environments through Singleton and SingleCall objects
  3. Using binary communication, .NET Remoting can provide support for rich type system.
  4. It requires the client be built using .NET, enforcing homogenous environment.

WCF Service:

  1. WCF support of almost all protocols like TCP, MSMQ, NamedPipe , Peer2Peer and HTTP.
  2. WCF Service works asynchronously.
  3. WCF service can be hosted on self hosting application, IIS and WAS (windows application service).
  4. WCF is used to implement Service oriented architecture. Service oriented architecture means collection of services communicated with each other with the help of messages


ABC of WCF Services

  • "A" stands for Address: Where is the service?
  • "B" stands for Binding: How do I talk to the service?
  • "C" stands for Contract: What can the service do for me?

Writing and configuring a WCF service is always a three-step process:

  • You define a contract and implement it on a service
  • You choose or define a service binding that selects a transport along with quality of service, security and other options
  • You deploy an endpoint for the contract by binding it (using the binding definition, hence the name) to a network address.


The contract is a platform-neutral and standard way of describing what the service does.

WCF defines four types of contracts.

  1. Service Contracts
  2. Data Contracts
  3. Fault Contracts
  4. Message Contracts

Service Contracts

Describe which operations the client can perform on the service. There are two types of Service Contracts.
ServiceContract - This attribute is used to define the Interface.
OperationContract - This attribute is used to define the method inside Interface.

Data contracts

Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.
There are two types of Data Contracts.
DataContract - attribute used to define the class
DataMember - attribute used to define the properties

If DataMember attributes are not specified for a properties in the class, that property can't be passed to-from web service.

Fault contracts

Define which errors are raised by the service, and how the service handles and propagates errors to its clients.

Message contracts

Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format we have to comply with.

Defining Service Contracts

A contract is defined explicitly, via a class. You add a [ServiceContract] attribute to the class. All methods you want to expose in your service, you mark as [OperationContract], as methods are called operations in services.

public class Hello
    string HelloWorld()
        return "Hello world";
    string HelloComputer()
        return "Hello computer";

It's always best to have an interface for our contract and have our actual service implement the interface. That's because

  • Interfaces can extend/inherit other interfaces
  • A single class can implement multiple interfaces
  • You can modify the implementation of a service without breaking the contract
  • You can version your service via old and new interfaces

The attributes also must be specified in the interface.

public interface IHello
   string HelloWorld();

   string HelloComputer();

public class Hello : IHello
   string IHello.HelloWorld()
       return "Hello world";

   string IHello.HelloComputer()
       return "Hello computer";

Defining Data Contracts

While a service contract defines the shape and rules for interfaces along with their associated messages and operations, the data contract defines the shape and rules for the data that is exchanged through operation's input and output messages.

See below a data contract for a person:

public class Person
  public int Id;
  public string FirstName;
  public string LastName;
This article shows the basic concept of WCF service. Although there are many other stuff needs to be understand but I think above is sufficient to achieve our basic goal: Add multiple pushpins on the Bing Map by fetching data from SQL Server.

In the next article I will show that….

Tags: bing maps, map, silverlight, bing, brh, Pushpin, #DOTNET, defining data contracts, wcf data contracts, web services, defining service contracts, abc of wcf, wcf, wcf services, wcf contracts, wcf service contracts, Windows Communication Foundation, #WCF, web services and wcf serices, #ASP.NET, .net remoting,

Dinesh Sodani
30 · 6% · 1807


Your Comment

Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]