background preloader

WCF

Facebook Twitter

WCF Service Library with Windows Service Hosting. Introduction Usually we prepare WCF services and host them in IIS which is useful when there are different clients accessing the service from outside the system.

WCF Service Library with Windows Service Hosting

But if the service is intended for local system clients, then it would be a better idea to host the WCF service as a Windows service. In this article we see how to create a WCF service and make it run as a Windows service. Using this application as sample anybody can design their applications in n-tier model using WCF. For this we follow a tiered architecture, where the service resides at one location, hosted at another and consumed from another location. To have a clear understanding about what we are going to do, here is the agenda: As our main intention is to show how to follow these steps, we are preparing a really simple service to make things less complicated. So, without much ado we start building our applications. WCF Concurrency (Single, Multiple, and Reentrant) and Throttling. Download source code - 63.4 KB Table of contents Introduction and goal In this article, we will concentrate on WCF concurrency and throttling.

We will first try to understand what is WCF concurrency and the three important types of WCF concurrency. We will then see a small sample of WCF concurrency with Single and Multiple. Courtesy: Pre-requisites In order to understand WCF concurrency well, it’s important to understand the concepts around WCF instancing. Why do we need concurrency in WCF? If you search on the web for the dictionary meaning of concurrency, you will find the following definition: “Happening at the same time” Three ways to do WCF instance management.

Download source code - 39.1 KB Table of contents Introduction Very often we would like to control the way WCF service objects are instantiated on a WCF server.

Three ways to do WCF instance management

You would want to control how long the WCF instances should be residing on the server. The WCF framework has provided three ways by which we can control WCF instance creation. There is a small ebook for all my .NET friends which covers topics like WCF, WPF, WWF, AJAX, Core .NET, SQL, etc., which you can download from here or you can catch me on my daily free training from here. WCF service object instancing basics In normal WCF request and response communication, the following sequence of actions takes place: Do not use "using" for WCF Clients. You know that any IDisposable object must be disposed using using.

Do not use "using" for WCF Clients

So, you have been using using to wrap WCF service’s ChannelFactory and Clients like this: using(var client = new SomeClient()) { . . . } Or, if you are doing it the hard and slow way (without really knowing why), then: using(var factory = new ChannelFactory<ISomeService>()) { var channel= factory.CreateChannel(); . . . } That’s what we have all learnt in school right? Failed: System.ServiceModel.CommunicationObjectFaultedException : The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

There are various reasons for which the underlying connection can be at broken state before the using block is completed and the .Dispose() is called. Then use this instead of the using keyword: Implementing a Basic Hello World WCF Service. Download source code - 42.5 KB Update An updated version of this article for .NET 4.5 can be found at Implementing a Basic Hello World WCF Service (v4.5) Introduction This is the first article I've written on WCF/LINQ.

Implementing a Basic Hello World WCF Service

In the first three articles on CodeProject.com, I'll explain the fundamentals of Windows Communication Foundation (WCF), including: In the other articles, I'll explain LINQ, LINQ to SQL, Entity Framework, and LINQ to Entities. Overview In this article, we will manually implement a basic WCF Service from scratch, step by step, with clear instructions and precise screen snapshots. WCF Callbacks; a beginners guide. On Channel9 last week Amiga forever! Wanted to know how to pass multiple parameters to a WCF callback; so as I covered callbacks at DDD Scotland briefly this seemed like a perfect excuse to illustrate how to create a callback in WCF.

So why do we want callbacks? One of remoting's more useful features was the ability for a server to trigger events on a client; WCF callbacks provide the same sort of facility. To start lets create a new WCF project by choosing the WCF Service Library in VS2008; You can see I'm targeting .NET 3.0; just to prove it will work in Visual Studio 2005 as well.

Next we need to define our service contract. So we add a new interface, IMessage, which will become our service contract. Namespace WcfCallbacks { using System.ServiceModel; [ServiceContract] interface IMessage { [OperationContract] void AddMessage(string message); } }