This is a mirror of official site: http://jasper-net.blogspot.com/

JSON Enabled WCF Services - Part 1

| Sunday, January 22, 2012
Introduction

This article describes the process of a WCF service configuration for working with data in JSON format. Although the configuring process seems to be simple, there are some particularities which cannot be ignored.


Background

As the lead developer in a multinational software company, I often develop Rich Internet Applications and do care about ensuring that an app would have a long and happy life. And lately, I have a really heavy headache when it comes to the decision about using the proper technology. From one side, the two most used ones are Silverlight and Flash. Both of them are cross-platform technologies, so an application created on Silverlight or Flash will look the same in all browsers.

From the other side, IMHO, these technologies have one serious disadvantage: they are limited in use. You can’t use a Silverlight application on Linux or a Flash application on iOS. I didn’t even mention mobile systems that are an essential part of our life. The majority of modern mobile devices and tablets don’t provide full support for Silverlight and Flash.

The use of HTML and JavaScript allows eliminating compatibility issues. All that’s needed to work with such applications is a web browser on any device.

I won’t bother you further with reasoning pros and cons of different technologies – I use them all, and the decision often depends on a particular project. But today I would like to tell you what made up my mind to choose HTML and JavaScript rather than other technologies for one of the projects I have been working on.


Creating a WCF service

In one of our projects, I decided to use HTML+JavaScript binding as a client part of an application. The client application interacts with a server to get data. It is possible to use a WCF service, MVC framework controllers, and Web Handlers as a service. In our case, we need to use a general format for data with which the client’s application and the service will interact. So, we had to choose what to use: XML or JSON. After some tests and considerations, we stooped on JSON. We had several reasons which determined the use of JSON.

Now, I want to tell you how we created the WCF service which passes data in JSON format.

The first step is to add a WCF service to the website.

Select the WCF Service in the Add New Item dialog window (I add the service with the WcfJsonService name). After this, the WcfJsonService.svc file is added to the application along with two files: IWcfJsonService.cs and WcfJsonService.svc.cs.


Read more: Codeproject
QR: JSON-Enabled-WCF-Services-Part-1

Posted via email from Jasper-net

0 comments: