chandransalem / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Unable to consume OData v2 JSON formatted response #214

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I have an OData v2 service
2. I am using OData4j 0.6
3. I do builder.setFormatType(FormatType.JSON);

I am able to consume my service using ATOM XML.

With JSON, I get this following exception for getEntities()

Exception in thread "main" java.lang.RuntimeException: 
java.lang.NullPointerException
    at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:50)
    at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:482)
    at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:482)
    at com.ca.garan10.odata.ODataClient.main(ODataClient.java:40)
Caused by: java.lang.NullPointerException
    at org.odata4j.format.json.JsonFormatParser.addProperty(JsonFormatParser.java:269)
    at org.odata4j.format.json.JsonFormatParser.parseEntry(JsonFormatParser.java:143)
    at org.odata4j.format.json.JsonFeedFormatParser.parse(JsonFeedFormatParser.java:136)
    at org.odata4j.format.json.JsonFeedFormatParser.parse(JsonFeedFormatParser.java:1)
    at org.odata4j.jersey.consumer.ConsumerQueryEntitiesRequest$EntryIterator.advance(ConsumerQueryEntitiesRequest.java:81)
    at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:48)
    ... 3 more

Original issue reported on code.google.com by gvnan...@gmail.com on 7 Sep 2012 at 10:20

GoogleCodeExporter commented 8 years ago
I am able to consume individual entity : /EntityType('ID') but not collection : 
/EntityType

So, to me this looks like a problem in consuming the OData v2 JSON format

My EntitySet response looks like below:

{
   "d":{
      "results":[
         {
            "__metadata":{
               "uri":"http://localhost:7000/node/odata/CA:00000_NodeA/Alert('Alert_8')",
               "type":"usm-core.Alert"
            },
            "Severity":"Fatal",
            "AlertType":"Risk",
         },
         {
            "__metadata":{
               "uri":"http://localhost:7000/node/odata/CA:00000_NodeA/Alert('Alert_7')",
               "type":"usm-core.Alert"
            },
            "Severity":"Fatal",
            "AlertType":"Risk",
         }
      ]
   }
}

Original comment by gvnan...@gmail.com on 7 Sep 2012 at 10:27

GoogleCodeExporter commented 8 years ago
Please close the issue. It was not a problem with OData4J but with my OData 
service.

My service did not respond with "DataServiceVersion" which should have been 
"2.0". Once I put that, it was able to consume JSON Verbose format.

Original comment by gvnan...@gmail.com on 7 Sep 2012 at 11:33

GoogleCodeExporter commented 8 years ago

Original comment by stephan....@googlemail.com on 7 Sep 2012 at 11:57