Category: WCF Everything


Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.

WCF Everything

WCF is used to design, implement and deploy distributed applications. While creating such applications was possible prior to the existence of WCF, WCF makes the development of endpoints easier than ever. In summary, WCF is designed to offer a manageable approach to creating Web services and Web service clients. WCF is designed using service oriented architecture principles to support distributed computing where services have remote consumers. Clients can consume multiple services; services can be consumed by multiple clients. Services are loosely coupled to each other. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, regardless of which platform the service is hosted on.

WCF Feature Highlight :

WCF is a flexible and robust platform. Here is the list of all major WCF features.

    1. Endpoints: Addresses, Bindings, and Contracts

    2. Data Transfer and Serialization

    3. Sessions, Instancing, and Concurrency

    4. Transports in Windows Communication Foundation

    5. Queues and Reliable Sessions

    6. Transactions

    7. Windows Communication Foundation Security

    8. Peer-to-Peer Networking

    9. Metadata

    10. Clients

    11. Hosting

    12. Interoperability and Integration

    13. WCF Web HTTP Programming Model

    14. WCF Syndication

    15. AJAX Integration and JSON Support

    16. WCF Discovery

    17. Routing

    18. Workflow Services

I will explore each and every feature listed here in coming blog posts. In Next post I will try to explain WCF architecture and fundamental terms.
Click “Follow” in right-bottom corner of your screen to subscribe to this blog and to have all new blog posts directly in your inbox.

I have been thinking to start a multi-part blog series targeting a latest Microsoft Technology. Purpose of which was to share my knowledge on the same and to acquire more in depth awareness on the technology. There were many techs on my list like C# language, Silverlight, WCF, Entity Framework, N-Hibernate, Telerik Controls etc… After enough brain storming for deciding on one of it, I have selected WCF – Windows Communication Foundation.

WCF Everything

Reasons for which I decided to write on WCF…

  1. For having more exposure to most trending, most buzzing technical terminology “SOA” – Service Oriented Architecture.
  2. All .Net client technologies like Silverlight, WPF, Windows Phone or even ASP.Net somewhere-somehow are integrating with WCF to communicate with another client, server or service. So while learning WCF, I will be having encounter-exposure to almost all diverse .Net technologies.
  3. Also targeting to take up MCTS certification in 2013 first quarter for which also I have decided to go with WCF.

Content of Blog Series…

  • It won’t be just WCF centric blog series at all. In fact while talking-writing about WCF we will also get in to integration details with other client techs also. And not just clients only but also we will try to have some exposure on WCF integration with latest stuff like caching, virtualization, cloud computing (largely on Microsoft Azure Platform).
  • Specifically I will start with explaining… What is WCF? Why is WCF required? Then progressively we will get in to ABC (Address, Bindings, and Contract) of WCF, SOAP, and REST with in-depth exploration of the same. And at last I will end up with high end integration scenarios like working with concurrency, transactions, sessions, web sockets and more.

Resources…

  • With each blog I will provide the source code for the samples I will be creating plus will provide with links to online docs, samples, videos on the related topic as well. And of-course comments, questions and discussions are always invited.
  • All the coding will be done in Dot Net Framework 4.5 with Visual Studio 2012 RC installed on Wndows 8 RC.
  • I will be writing all WCF blogs under new category called “WCF Everything”. I also will be keep writing on non WCF .Net stuff as well. So be prepared, be ready for some exciting reading on WCF.
Click “Follow” in right-bottom corner of your screen to subscribe to this blog and to have all new blog posts directly in your inbox.

 

 

 

Currently I am working on a sample project in .net 4.0 and in which I am using Entity Model to expose my Data from SQL Server 2008 database.
Now I am also using POCO entities as in .Net 4.0 POCO entities gives us better control over the entities we are using to map with the entities in the Entity Model compare to the auto generated entities generated by Entity Model itself.
Now here are my two POCO entities ‘User’ and ‘Account’….

Click the image for full view…….

Now I am querying data from SQL using LINQ to SQL as shown below in code…….

This code should return the ‘Account’ with users in it but instead it returns no data in browser or no Error/ Exception as well but simply shows “Webpage can’t be displayed” in IE8 as shown in the image below…..

Now I just tried to figure out the issue but not found anything as there was no error or Exception in the code and the only symptom of this issue was that when I was debugging the code it comes to the debug point twice in the method where I am using LINQ to SQL. The good thing was it was showing the correct results inside the variable ‘accountList’ but was not showing any result in the browser.

Then I suddenly notice that my ‘Account’ entity has the property ‘Users’ of type [List of ‘User’] (Angle brackets not allowed here) and then again each User has the property ‘Account’ and again each ‘Account’ has List and seems like infinite dependency on each other….

So what I tried for the solution was, I just added the attribute [IgnoreDataMember] (using System.Runtime.Serialization assembly) on ‘Account’ property in my ‘User’ entity class as shown below in image……..

And tested it again…. and guess what…. Bingoooo…. It just simply works and now browser shows the correct data as shown in image below……

Click the image for full view…….

So what I guess is that it was happening because of kind of infinite circular dependency created by data model I am using.

(If I am not using extention method ‘Include()’ in my LINQ to SQL, it works just fine and returns the Accounts without ‘Users’ off course)

But the question that still remains is, it’s the known issue or the unexplored bug of using LINQ to SQL with POCO entities.

For last 3-4 days I am trying to understand the RESTful architecture for applications.
And so for start I have created a sample REST service using “WCF REST Service Application” template in Visual Studio 2010 RC and .Net Framework 4.

At first I have tested service operations of my REST service with ‘GET’ & ‘POST’ and they were working absolutely OK.
(I have not created any client yet to test my RESTful service but I am using ‘Fiddler‘ for the purpose.)

Now when I have started testing with ‘PUT’ verb in my request to REST service through fiddler, it has returned Http Error 405 (‘Method not Allowed’).
Then I started testing ‘DELETE’ and it was also not working with the same Http Error 405.

As I am like newbie to REST Services and IIS stuff and all that, I have not understand the error described in Image above.
So I have googled this Error a lot but not found the appropriate answer and so ultimately put the question on official IIS forum as I have found by the time that, this Error is related to IIS……

Link to IIS Forum My thread ==> http://forums.iis.net/t/1166025.aspx

And Bingo……. I got the answer from the forum so quickly and that just simply worked.

The issue was WEB DAV module on IIS was throwing the Http Error 405 as it was claiming to process the request sent by my application on IIS, but my application is not configured to process it with WEB DAV module which do not support ‘PUT’ and ‘DELETE’ verbs by default.

So as a solution I have just removed WEB DAV module from my IIS 7…….
Go to IIS Manager ==> Default Web Site ==> MyRESTApplication ==> Modules(In Features View) ==> WEB DAV Module (On module right click) ==> Remove

Now evrything in my RESTful application works just great…