Note that there are some explanatory texts on larger screens.

plurals
  1. PORestlet Android doesn't connect to oData service
    text
    copied!<p>I just can't get Restlet on Android to work. I have the same jars, same generated classes etc. that I use in plain Java (it works there). Problem seems to be with the HttpClientHelper. </p> <p>I also read this: <a href="http://wiki.restlet.org/docs_2.1/13-restlet/275-restlet/266-restlet.html" rel="nofollow">http://wiki.restlet.org/docs_2.1/13-restlet/275-restlet/266-restlet.html</a>. </p> <p>Here's my code: </p> <pre><code>import netflix.catalog.v2.Genre; import org.restlet.engine.Engine; import org.restlet.ext.net.HttpClientHelper; import org.restlet.ext.odata.Query; Engine.getInstance().getRegisteredClients().clear(); Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null)); SystemDataObjectsService service = new SystemDataObjectsService(); Query&lt;Genre&gt; query = service.createGenreQuery("/Genres"); for (Genre g : query) { Log.d(TAG, g.getName()); } </code></pre> <p>Here's the trace: </p> <pre><code>11-16 13:02:31.915: I/org.restlet(1344): Starting the HTTP client 11-16 13:02:31.924: I/org.restlet(1344): A recoverable error was detected (1001), attempting again in 2000 ms. 11-16 13:02:33.935: I/org.restlet(1344): A recoverable error was detected (1001), attempting again in 2000 ms. 11-16 13:02:35.955: E/org.restlet(1344): Can't get the metadata for http://odata.netflix.com/v2/Catalog/ (response's status: Communication Error (1001) - The connector failed to complete the communication with the server) 11-16 13:02:35.965: W/org.restlet(1344): Can't parse the content of http://odata.netflix.com/v2/Catalog/Genres 11-16 13:02:35.965: W/org.restlet(1344): java.lang.Exception: Can't execute the query without the service's metadata. 11-16 13:02:35.965: W/org.restlet(1344): at org.restlet.ext.odata.Query.execute(Query.java:350) 11-16 13:02:35.965: W/org.restlet(1344): at org.restlet.ext.odata.Query.iterator(Query.java:645) 11-16 13:02:35.965: W/org.restlet(1344): at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:74) 11-16 13:02:35.965: W/org.restlet(1344): at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:1) 11-16 13:02:35.965: W/org.restlet(1344): at android.os.AsyncTask$2.call(AsyncTask.java:264) 11-16 13:02:35.965: W/org.restlet(1344): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 11-16 13:02:35.965: W/org.restlet(1344): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 11-16 13:02:35.965: W/org.restlet(1344): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 11-16 13:02:35.965: W/org.restlet(1344): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 11-16 13:02:35.965: W/org.restlet(1344): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 11-16 13:02:35.965: W/org.restlet(1344): at java.lang.Thread.run(Thread.java:856) 11-16 13:02:35.965: W/dalvikvm(1344): threadid=11: thread exiting with uncaught exception (group=0x409c01f8) </code></pre> <p>I also tried to import org.restlet.ext.httpclient.HttpClientHelper (and any other HttpClientHelper that Eclipse suggests) which lead to a slightly different trace: </p> <pre><code>11-16 13:06:27.775: I/org.restlet(1446): Get the metadata for http://odata.netflix.com/v2/Catalog/ at http://odata.netflix.com/v2/Catalog/$metadata 11-16 13:06:27.815: I/org.restlet(1446): Starting the HTTP client 11-16 13:06:27.836: W/org.restlet(1446): An error occurred during the communication with the remote HTTP server. 11-16 13:06:27.836: W/org.restlet(1446): java.net.UnknownHostException: Unable to resolve host "odata.netflix.com": No address associated with hostname 11-16 13:06:27.836: W/org.restlet(1446): at java.net.InetAddress.lookupHostByName(InetAddress.java:400) 11-16 13:06:27.836: W/org.restlet(1446): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242) 11-16 13:06:27.836: W/org.restlet(1446): at java.net.InetAddress.getAllByName(InetAddress.java:220) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 11-16 13:06:27.836: W/org.restlet(1446): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.ext.httpclient.internal.HttpMethodCall.sendRequest(HttpMethodCall.java:335) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.engine.http.adapter.ClientAdapter.commit(ClientAdapter.java:120) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.engine.http.HttpClientHelper.handle(HttpClientHelper.java:113) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.Client.handle(Client.java:180) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.resource.ClientResource.handle(ClientResource.java:944) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.resource.ClientResource.handle(ClientResource.java:912) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.resource.ClientResource.handle(ClientResource.java:867) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.resource.ClientResource.handle(ClientResource.java:892) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.resource.ClientResource.handle(ClientResource.java:801) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.resource.ClientResource.get(ClientResource.java:544) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.ext.odata.Service.getMetadata(Service.java:483) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.ext.odata.Query.&lt;init&gt;(Query.java:232) 11-16 13:06:27.836: W/org.restlet(1446): at org.restlet.ext.odata.Service.createQuery(Service.java:277) 11-16 13:06:27.836: W/org.restlet(1446): at net.ascorbin.locaspo.SystemDataObjectsService.createGenreQuery(SystemDataObjectsService.java:87) 11-16 13:06:27.836: W/org.restlet(1446): at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:71) 11-16 13:06:27.836: W/org.restlet(1446): at net.ascorbin.locaspo.MainActivity$LoginTask.doInBackground(MainActivity.java:1) 11-16 13:06:27.836: W/org.restlet(1446): at android.os.AsyncTask$2.call(AsyncTask.java:264) 11-16 13:06:27.836: W/org.restlet(1446): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 11-16 13:06:27.836: W/org.restlet(1446): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 11-16 13:06:27.836: W/org.restlet(1446): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 11-16 13:06:27.836: W/org.restlet(1446): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 11-16 13:06:27.836: W/org.restlet(1446): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 11-16 13:06:27.836: W/org.restlet(1446): at java.lang.Thread.run(Thread.java:856) 11-16 13:06:27.836: I/org.restlet(1446): A recoverable error was detected (1001), attempting again in 2000 ms. </code></pre> <p>I don't know what else to do, if someone has a running Restlet/ oData android project, perhaps he/ she can give me a hint?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload