Vishwamohan

Welcome to Vishwa's blog - Technology, Spirituality and More...

Error: A call to SSPI failed

If you are configuring your client application to use WCF net TCP binding, you may come across the following error. A call to SSPI failed, see inner exception.The target principal name is incorrect [More]

WCF Service Hosted in Web Farm or Multi-Homed Scenario

If a WCF Service is deployed in a load balanced environment and hosted on multiple Web Servers under IIS, which is accessed on a public domain, WCF WSDL document refers to a the responding machine name which is generally inaccessible on a public domain. So what you should be doing to make it right? [More]

Implementing WCF Service Part 6 – Using Fault @ Client

Ok, so you have developed a nice WCF Service with proper implementation of custom fault exception handling, now you want to call this service in a web application or other client application and catch the fault exception in your client code. For simplicity I am using a web page, the following code is self explanatory. [More]

WCF Service Error: The maximum message size quota ...

If you are using a WCF (Web) Service in client application and dealing with large data, at some point you may come across an error message:

{"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."} Here is the solution. [More]

Implementing WCF Service Part 5 - Fault Contract

In WCF, there are five major contracts – Service Contract, Operation Contract, Data Contract, Fault Contract and Message Contract. In my previous examples I used first three. In this example, I will implement the Fault Contract. I am not very fond of using Message Contract as some guidelines suggest using the least or based on requirement, however you cannot get away from the first four contracts. In the event of Fault (exception), WCF throws a fault containing detail error message which you may not like to be passed back to the caller. In other words, this example focuses on how to hide full error details and provide a custom error code, message and details. You can use multiple Fault Contracts on one Operation Contract in similar way. This example provides a simple and generic way to handle Faults. [More]

Implementing WCF Service Part 4 - POX/REST

This post will focus on implementing POX (Plain Old XML) and REST (Representational State Transfer) in WCF. In other words this is an implementation of the old HTTP XML Post. I spent not several hours but several days to figure out the solution. As all of you know making HTTP GET is easy in WCF but HTTP Post (without using SOAP) is a different story. I researched all around the web but nowhere found a simple example for this option, yes not even on Microsoft site. Many people just post their opinion in few lines and then you keep guessing, and if you are new to this then keep doing trial and error method for hours and days provided you keep your patience on. Once you will find the solution, it will look so easy. [More]

Implementing WCF Service Part 3 - SOAP/XML

In this post, I will implement the basicHttpBinding, through which you can even use a HTML page and JavaScript to consume the WCF Service via SOAP based XML. I spent several hours to exactly figure out the SOAP format. In ASMX web service, if you will click on a method, it shows you the sample SOAP format for request and response. Unfortunately, that is not available in WCF Service page right now, so you have to figure out or use a tool to see what is being passed or expected. The Serialization used in ASMX Web Service is based on XML Serialization; however WCF uses a different mechanism for the same. You can use the old SOAP format (which I used in ASMX Web Service) to post the transaction but you will always get SOAP 1.2 format response. In order to keep consistency, I kept the request format similar to response. [More]

Implementing WCF Service Part 2 - Client

I will consume the Customer WCF Service which I developed in Part 1 on WS* Http Binding, you can implement the best security, transactions and many more things using this way. However, I will consume in a very simplistic way in this post. I assume that you have already deployed the WCF Service under IIS and have a working URL ready to be referenced and you are planning to use the customer WCF service in ASPX web Page. [More]

Implementing WCF Service Part 1 - Service

As you know, the New Windows Communication Services (WCF) will replace the existing ASP.NET ASMX Web Services. So, it will be wise to plan it from today as how to transit in this new service model era. I first tried experimenting with WCF Service almost a year ago with the release of .NET 3.0 but VS 2005 and VISTA did work happily on my machine but now I like VS 2008. I revisited WCF again with the release of .NET 3.5, all the sample available on the web are either old or do not give enough information if you are looking for information as how to use this service in different way over different protocol, which can closely mimic a small real word example . So, I had to spend hours trying to find solutions and put the pieces together. So, I finally thought to create an example to help others who are facing the same situation. I have tried to closely mimic the ASMX Web Service uses, which I posted in my earlier post because most of us will be planning to convert from existing old one. With all the experiments I would give one key Mantra for WCF, dig the Config file specially to understand how to configure BEB (Binding, Endpoint and Behavior). This example deals with CRUD operation on Customer data which I used in earlier post. For the simplicity I am using XML file for the data source and will consume this service with WS* Standard, SOAP based XML POST, Plain Old XML (POX) and HTTP GET and POST. I believe these are the common uses along with TCP, named pipe and MSMQ. [More]