4

I am trying to query a WCF OData service from Java using the odata4j library. If I query a entity using ATOM format, everything is OK. If I switch to JSON, Java throws 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 produced 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 is not able to find an entity "GetStatesViewData?gac=0", but such a property does not exist. What exists is a service operation "GetStatesViewData" which accepts a parameter "gac". Is it possible to call a service operation with parameters using OData4j?

If I use Fiddler or some other web debugger, send a HTTP request with a "accept: application/json" header to this OData Service, I normally get the JSON feed. So there is something wrong either in OData4j or in my code, the OData server seems to be OK.

Tomas Walek
  • 2,516
  • 2
  • 23
  • 37
  • It behaves the same If I query an entity and not a service method, so it is not a problem of missing support for service methods. – Tomas Walek Oct 27 '11 at 08:00

1 Answers1

3

Currently (as of version 0.5) - you can use callFunction to call a service operation.

See FunctionTest.java on the odata4j Github repo for an example.

Hope that helps,
- john

Ken Pespisa
  • 21,989
  • 3
  • 55
  • 63
John Spurlock
  • 1,723
  • 1
  • 13
  • 12