Tag: WCF
-
Don’t Create REST APIs with WCF REST Services…use Web API Instead
There was time when developers used to create Web Service using the WCF. Their argument was using basicHttpBinding makes a WCF service as a Web Service. Yes that ASMX based web service. I never agree to this argument. Clearly WCF was an evolvement over ASMX Web Service. Now let us talk about purpose of this…
-
Generics in WCF Data Contract
In my WCF training, I often get questions that can we expose a generic type as DataContract in WCF? Yes, WCF allows us to expose the generic types as Data Contract. Let us say we have a generic type Foo. We can apply data contract on the Foo as follows: We can use Foo<T>…
-
Data Contract Serialization Events in WCF
In WCF we use the DataContract to serialize and deserialize the custom data. Sometime you may come across a scenario do some work before or after the data gets serialized or deserialized. These are following four events provided on the DataContract. You are free to give any method name provided method should return void and…
-
Multiple bindings in self-hosted WCF Service
Even though WCF is now, more than 5 years old but still I see developers struggling with the multiple bindings specially when hosted in a managed console application. In this post, step by step we will learn to create a WCF Service with multiple bindings and host the service in a managed console application. We…
-
Fault Contract’1 was unhandled by user code: Solved
For a training purpose I was trying a basic demo on fault contract in WCF and to be surprised I Got below error while throwing FaultException. It’s not that 1st time I was working on Fault Contract but this error was irritating. After some investigation I found there was some issue in visual studio 2013…
-
Publish WCF Service in Local IIS on Visual Studio 2013
Long back I wrote a blog post Step by Step hosting WCF Service in IIS 7.5 . In this post I used Visual Studio 2012 as I remember. Today I was trying to host WCF in local IIS in Visual Studio 2013 and found it is surprisingly easy to host WCF Service in IIS 2013…
-
Solved Access-Control-Allow-Origin Error in WCF REST Service
Recently I was working on a JSON based WCF REST Service. It was a simple service performing CRUD operation. When I tried to consume service from a web based client, got following errors in browser console. Error message was, No Access-Control-Allow-Origin header is present on the required resource. Since service was running on different…
-
Dealing Multiple EndPoints of a WCF Service
If you know EndPoints well, you know WCF well. Configuring EndPoints are vital for any WCF design. You can configure EndPoints either via code or in web.config file. I have seen many times, developers are confused with EndPoints. I have come across following common question about EndPoints Can we have multiple EndPoints? Can be expose…
-
All about Instance Management in WCF
When I started learning WCF, First thing I learnt was “Service is just like another class”. Okay so if WCF is a class which instance of class will handle request from client? Confusing? May be! In this post let us explore WCF Instance Management. In WCF, Instance Management is a technique to decide which service…
-
Return type of One-way or Simplex WCF Service
WCF is one of the most asked topics in interviews. Recently one of my reader sent me a mail. He asked, “What is error in following code?” His code snippet was as below, In one sentence, problem with above code is in return type of Operation Contract. IsOneWay property of Operation Contract is set to…