RIA Services - exposing JSON endpoint

Go through RIA Services - using Entity Framework article which demonstrates step by step approach to expose and consume Domain service in Silverlight application.

This article speaks about exposing JSON endpoint which can be consumed by AJAX client.

By default only Binary endpoint is enabled for domain services. To use the Binary endpoint no additional configuration is needed. But to enable JSON endpoint you have to do small change. Enabling JSON endpoint does not need any change in domain service, you have to just register endpoint factory in the Web.config file.

        <add name="JSON" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

And you must add reference of "Microsoft.ServiceModel.DomainServices.Hosting" assembly in web project. The Microsoft.ServiceModel.DomainServices.Hosting.dll assembly is part of WCF RIA Services toolkit, to use this you must first install WCF RIA Services toolkit.


Now build your application, to see the JSON output hit below URL.


Note that the URL is combination of namespace and domain service name. The "GetStudent_detail" is method in domain service.


When you hit the URL it will prompt you to save the output, you may save it in your system and open it in notepad. The above image is showing output in notepad.

Up Next
    Ebook Download
    View all
    View all