Shiju Varghese's Blog Headline

Shiju Varghese's Blog

Wednesday, November 28, 2007

JSON Supports in WCF with .Net 3.5

JSON (JavaScript Object Notation) is a lightweight data-interchange format. JSON is a text format language and becoming a common data-interchange standard for Ajax communication. Most of the Ajax applications are using JSON for communication between the client and server because JSON is faster than XML and easy to manipulate.

In .Net 3.5, WCF can supports JSON. You can send and receive JSON objects from WCF. You need to change config file to support JSON.

The following config that enables JSON support from WCF


<service name="OrderService">
<endpoint contract="IOrders"
binding="webHttpBinding"
bindingConfiguration="jsonBinding"
address=""
behaviorConfiguration="jsonBehavior" />
</service>

<webHttpBinding>
<binding name="jsonBinding" messageEncoding="Json" />
</webHttpBinding>
<behaviors>
<endpointBehaviors>
<behavior name ="jsonBehavior">
<webScriptEnable />
</behavior>
</endpointBehaviors>
</behaviors>

No comments: