I am trying to query the WCF OData service with Java using the odata4j library. If I request an object using the ATOM format, everything is fine. If I switch to JSON, Java throws the following exception:
java.lang.RuntimeException: java.lang.RuntimeException: EdmEntitySet GetStatesViewData?gac=0 not found at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:49) at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:487) at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:487) at ... Caused by: java.lang.RuntimeException: EdmEntitySet GetStatesViewData?gac=0 not found at org.odata4j.edm.EdmDataServices.getEdmEntitySet(EdmDataServices.java:40) at org.odata4j.internal.EdmDataServicesDecorator.getEdmEntitySet(EdmDataServicesDecorator.java:31) at org.odata4j.format.json.JsonFeedFormatParser.parse(JsonFeedFormatParser.java:99) at org.odata4j.format.json.JsonFeedFormatParser.parse(JsonFeedFormatParser.java:21) at org.odata4j.consumer.OQueryRequestImpl$EntryIterator.advance(OQueryRequestImpl.java:192) at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:47) ... 10 more
The following code raised this exception: ODataConsumer odc =
ODataConsumer.create(FormatType.JSON, "http://localhost:6000/"); Iterator<OEntity> iterator = odc.getEntities("GetStatesViewData?gac=0").execute(); for(OEntity entity: entities) { .. }
OData4j cannot find the "GetStatesViewData? Gac = 0" object, but such a property does not exist. What exists is the GetStatesViewData service operation, which takes the gac parameter. Is it possible to call a service operation with parameters using OData4j?
If I use Fiddler or some other web debugger, send an HTTP request with the header "accept: application / json" to this OData service, I usually get a JSON channel. So there is something wrong with OData4j or in my code, the OData server seems OK.
source share