0

I have written my odata service consumer code which supports Odata V3. I have written Logic as mentioned here Consume Odata Service and get result in JSON

The java odata service which I am consuming is written in Odata V2. Now I want to get result as Json what is the approach. Please help.

I have tried following apporaches but I failed to get result: 1. UseJson method of data context but it supports only odata service version 3 or higher. 2. passing header as json but it gives me error.

Community
  • 1
  • 1
user2463514
  • 273
  • 1
  • 4
  • 19

1 Answers1

1

Unfortunately, if your server does not support v3 of OData, you cannot use the WCF Data Services client with JSON.

You can still use the WCF Data Services client with Atom. Is this acceptable for your scenario?

Alternatively, if you must use the old JSON format, you could use ODataLib (available on NuGet as Microsoft.Data.OData) to read and write verbose JSON payloads. ODataLib is a low-level serialization and deserialization library for OData payloads; you won't get the niceness of the WCF Data Services client library, and you'll have to implement materialization, entity tracking, etc., on your own, but it's a lot better than just using JSON.NET (or a similar library) directly.

My blog, http://odata.jenspinney.com/, has some examples of using ODataLib. If you decide to go this route, feel free to ask questions on how to get specific scenarios working.

Jen S
  • 4,465
  • 1
  • 32
  • 28
  • 1
    Thanks for the response. You have nice blog – user2463514 Jul 10 '13 at 10:28
  • I have initially started with ODataLib only but to use it we have to write lots of code as you have also mentioned. – user2463514 Jul 10 '13 at 10:29
  • Can you confirm me if in future microsoft has any plan to remove json verbose from odata ? or both json light and verbose will be there ? – user2463514 Jul 10 '13 at 10:31
  • In V4 of OData, JSON verbose is going away completely. This is not just Microsoft's decision -- the v4 protocol is being standardized and the standards committee is made up of people from various companies. I do expect Microsoft's investment in verbose JSON to get a much smaller as OData v4 comes out. – Jen S Jul 10 '13 at 16:27
  • Using ODataLib is going to be a lot more work than wcf data services. Why not use Atom instead? – Jen S Jul 10 '13 at 16:28
  • Do you have any official link where it is mentioned Verbose Json (format of json supported in V1 & V2) is going away completely. The reason I am asking is that so I can forward this to my boss. – user2463514 Jul 11 '13 at 07:06
  • Atom is second option if I will able convence them Json will not work then we are going to use compressed Atom. – user2463514 Jul 11 '13 at 07:08
  • The work-in-progress spec for OData v4 [here](http://docs.oasis-open.org/odata/odata/v4.0/csprd01/part1-protocol/odata-v4.0-csprd01-part1-protocol.html#_Toc355089380) says the two formats of OData are Atom and JSON. The document linked to for the JSON format describes the new JSON format and not the old one. Verbose JSON will still exist in the protocol versions 1 and 2, but given that it's going away in v4 of the protocol, I would not expect people making libraries (whether that's Microsoft or otherwise) to put much time into verbose JSON support. – Jen S Jul 11 '13 at 19:48
  • It is difficult to convence somebody based on assumption :( – user2463514 Jul 12 '13 at 08:52
  • Unlike the v1 through v3 specs, there is no description of json verbose anywhere in v4. If you look at the definition of the json format, it is not json verbose. I work at Microsoft on the OData team -- you can tell your boss someone from Microsoft told it's going away. If your boss still doesn't believe that json verbose is going away in v4, he can email the odata mailing list and get a response from the larger OData community. – Jen S Jul 12 '13 at 15:41
  • Thanks for your response and help. – user2463514 Jul 15 '13 at 11:01
  • Is compression support by WCF Data Services client ? – user2463514 Jul 16 '13 at 07:17