Restlet createQuery fails with connection error (and after workaround NoSuchMethodError)

喜你入骨 提交于 2019-12-25 08:02:02

问题


I followed the Android restlet tutorial and tried to consume a sample OData webservice (http://services.odata.org/OData/OData.svc/). When I create a query with myService.createProductQuery("/Products"); logcat tells me that

ERROR/org.restlet(700): Can't get the metadata for ...

A problem similar to this question. I did try and register the Apache client as suggested by Jerome Louvel:

Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null)); 

Unfortunately I get a new error. On Query initialization I get a NoSuchMethodError exception. The Query class seems to want to call MyService.getMetadatada(). From the docs I see this is a protected method on org.restlet.ext.odata.Service

Happens on version 2.0.11 and 2.1rc3 of Restlet.

Additionally I also tried a home-made .NET 4.0 WCF webservice, with the same results. Any help would be appreciated.


回答1:


For future readers that come upon this question: just make double sure your Manifest file sets permission on your application to access the internet. (For shame). Obviously it needs access to the network to "call" the webservice.

..
<uses-permission android:name="android.permission.INTERNET"></uses-permission>


来源:https://stackoverflow.com/questions/9601983/restlet-createquery-fails-with-connection-error-and-after-workaround-nosuchmeth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!