MSDN Sample – WCF

Software development approaches are becoming better day by day. First development was done using procedural programing. Then object oriented programming was introduced. Now service oriented architecture (SOA) become the main stream standered of many application. Microsoft’s new approach towards SOA is Windows Communication Foundation (WCF). From .NET Framework 3.0 they introduced WCF. In WCF Microsoft bring all the service approach like XML web service, .NET Remoting under one roof. So now using WCF we can create many different end point of a single service. For example one for HTTP another for TCP. Also there are contracts like Service contract, Operation contract, Data contract, fault contract. The three main thing of WCF is Address, Binding and Contract together is called ABC of WCF.

I am posting a new code sample in MSDN today. Yes this sample is related to WCF. This is a very basic example of WCF. In this solution there are two projects. One is a WCF service and another ASP.NET web application. WCF is actually providing the Planet Wrox Genre and Review data. ASP.NET web application is consuming the functionality which is provided by the WCF service.

[ServiceContract]
public interface IGenreService
{
    [OperationContract(Name = "GetAll")]
    IList Get();

    [OperationContract(Name = "GetById")]
    Genre Get(int genreId);
}

[DataContract]
public class Genre
{
    [DataMember]
    public int Id { get; set; }

    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public int SortOrder { get; set; }
}

public class GenreService : IGenreService
{
    public IList Get()
    {
        // Put your implementation.
    }

    public Genre Get(int genreId)
    {
        // Put your implementation.
    }
}

You can view or download the full code from MSDN sample.

Always it is very nice feelings to get a healthy number of downloads and ratting in MSDN code sample. So keep commenting and downloading.

Good buy for today.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s