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. 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. Creating WCF Service Library i. This step will create an IJobs interface and Jobs class. Ii. Iii. Iv. I. Ii. 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. We will then go through 9 combinations of WCF concurrency and instancing. Finally we will try to understand how to configure throttling using the WCF ‘web.config’ file.

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” WCF concurrency helps us configure how WCF service instances can serve multiple requests at the same time. Three types of WCF concurrency Reentrant. 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. 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.

In this article, we will first try to understand those three ways of WCF service instance control with simple code samples of how to achieve them. 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: WCF client makes a request to a WCF service object.WCF service object is instantiated.WCF service instance serves the request and sends the response to the WCF client.

Per call Single. Do not use "using" for WCF Clients. You know that any IDisposable object must be disposed using using. 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. 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.

We will build the WCF Service manually from scratch, meaning we will not use any Visual Studio 2010 template to create the service. We will build a HelloWorld WCF Service by carrying out the following steps: Creating the HelloWorld solution and project Before we can build the WCF Service, we need to create a solution for our service projects. Start Visual Studio 2010. Add a using statement: 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); } } This would be enough for a simple server scenario; but because we want to support callbacks we need to do a couple more things.