Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8715005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:44:30+00:00 2026-06-13T05:44:30+00:00

I am building a WCF data service (with .net 4.5 VS 2012) using Reflection

  • 0

I am building a WCF data service (with .net 4.5 VS 2012) using Reflection Provider (http://msdn.microsoft.com/en-us/library/dd728281.aspx) on my existing classes. I can successfully access the service with “Accept: application/atom+xml” in request header. however, I got an error “Unsupported media type requested” when changing “Accept” to “application/json” in request header. As I learned, WCF data service supports JSON, what should I do to enable querying json data on the service?

Thanks

Edit:
I paste my code below:
first I have the Product class defined:

[DataServiceKeyAttribute("Id")]
public class Product
{
    public int Id { get; set; }
    public int Price { get; set; }
    public string Name { get; set; }
}

then I have my ProductContext class defined:

public class ProductContext
{
    private List<Product> products = new List<Product>();

    public ProductContext()
    {

        for (int i = 0; i < 100; i++)
        {
            var product = new Product();
            product.Id = i;
            product.Name = "ID - " + i.ToString();
            product.Price = i + 100;
            products.Add(product);
        }
    }

    public IQueryable<Product> Products
    {
        get
        {
            return products.AsQueryable();
        }
    }
}

and my ProductService.svc.cs

[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class ProductsService : DataService<ProductContext>
{
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    {
        // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
        // Examples:
        config.SetEntitySetAccessRule("Products", EntitySetRights.AllRead);
        //config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:44:31+00:00Added an answer on June 13, 2026 at 5:44 am

    If you’re using WCF Data Services 5.0, takes a look at this blog post which explains the changes in JSON support: http://blogs.msdn.com/b/astoriateam/archive/2012/04/11/what-happened-to-application-json-in-wcf-ds-5-0.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem Background I'm building a custom WCF Data Service provider using the Alex James
I'm trying to follow a guide from http://kellabyte.com/2010/11/13/building-extensible-wcf-service-interfaces-with-datacontractresolver/ to create and attach a DataContractSerializer.
I created a simple WCF web service(following this tutorial: http://blogs.msdn.com/b/ericwhite/archive/2010/05/11/getting-started-building-a-wcf-web-service.aspx ), because I don't
I'm building a self hosted WCF service. I'm building a special data structure for
I'm currently building a reporting service (WCF) - filled reports are produced using an
I'm new to REST and I'm building a service using the WCF REST Starter
I am building a service using WCF and I need to send over images.
I am building a simple WCF service that has to return some data from
I have a WCF web service that is building up data into classes and
I am creating a WCF Data Service using the WCF Data Services Toolkit and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.