Android Restlet HTTPS

房东的猫 提交于 2019-12-06 02:36:47

问题


When trying to get some data on my android client from my webservice (running on app-engine) with this code

ClientResource cr = new ClientResource("https://myapp.appspot.com/restlet/service/");
IServiceResource res = cr.wrap(IServiceResource.class);
m_Services = res.getServices();

I get this error:

05-20 08:30:15.406: ERROR/AndroidRuntime(31767): Caused by: Communication Error (1001) - Could not change the mode after the initial handshake has begun.

i have the org.restlet.ext.ssl.jar for the https-support and i am using this line to add the client

Engine.getInstance().getRegisteredClients().add(new HttpsClientHelper(null));

this is the closest i have come to getting https:// calls to work since i moved up to restlet 2.1m4 (moved because i was in need of entityBuffering..)

Any ideas? Any other information i need to share?


回答1:


Got it working. Changed HttpClient to org.restlet.ext.net.

On Android, you are told to do this to change the client

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

However nothing changes by doing so, instead, i had success with

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

This solves the issu(be sure to have org.restlet.ext.ssl in your build path aswell). This also solves other issues such as the "Internal Connector Error (1002) - The calling thread timed out while waiting for a response to unblock it."




回答2:


I had worked with web service using ksoap2, u can try using ksoap2 by downloading the jar and including in ur project.



来源:https://stackoverflow.com/questions/6068303/android-restlet-https

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