androidodataodata4j

odata4j consumer function call


I am having a problem with calling a ext function in odata4j in android client consumer. E.g. the function "Movies" of Netflix public service.

METADATA of function:

<FunctionImport Name="Movies" EntitySet="Titles" ReturnType="Collection(Netflix.Catalog.v2.Title)" m:HttpMethod="GET"/>

and my code:

ODataConsumer c = ODataConsumer.create("http://odata.netflix.com/Catalog/");
c.dump.all(true);
Enumerable<OObject> e = c.callFunction("Movies").execute();

With this callFunction method ends with following error.

01-27 10:03:49.796: E/AndroidRuntime(264): Uncaught handler: thread main exiting due to uncaught exception 
01-27 10:03:49.815: E/AndroidRuntime(264): java.lang.NoSuchMethodError: org.w3c.dom.Text.getTextContent
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.core4j.xml.XContainer.parseNode(XContainer.java:67)
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.core4j.xml.XDocument.<init>(XDocument.java:26)
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.core4j.xml.XDocument.load(XDocument.java:90)
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.core4j.xml.XDocument.parse(XDocument.java:73)
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.odata4j.consumer.ODataClient.dumpResponseBody(ODataClient.java:263)
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.odata4j.consumer.ODataClient.doXmlRequest(ODataClient.java:247)
01-27 10:03:49.815: E/AndroidRuntime(264):  at org.odata4j.consumer.ODataClient.getMetadata(ODataClient.java:69)
...

Interesting is, when I delete row with c.dump.all(true) the callFunction is without error but cannot access data.

01-27 13:25:33.795: E/AndroidRuntime(534): Caused by: java.lang.UnsupportedOperationException: Not supported yet.
01-27 13:25:33.795: E/AndroidRuntime(534):  at org.odata4j.format.FormatParserFactory$AtomParsers.getCollectionFormatParser(FormatParserFactory.java:125)
01-27 13:25:33.795: E/AndroidRuntime(534):  at org.odata4j.format.FormatParserFactory.getParser(FormatParserFactory.java:52)
01-27 13:25:33.795: E/AndroidRuntime(534):  at org.odata4j.consumer.ConsumerFunctionCallRequest$FunctionResultsIterator.advance(ConsumerFunctionCallRequest.java:196)
01-27 13:25:33.795: E/AndroidRuntime(534):  at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:48)
...

I am not sure if I understand correctly the callFunction method. There are EntitySet and ReturnType attributes in metadata entry of the function but I suppose I can access the result as OObject(s). Or am I wrong? Is there any example how to get function response and access its data. Could anybody help me with this please. Thank you very much.

Jiri


Solution

  • I've met the same problem. As the exception error message suggested, Odata4j 0.5 currently does not handle the response from a function call. If you have a look at the source code, you will see.