Android Restlet HTTPS

时间:2011-05-20 06:36:38

标签: android https restlet

尝试使用此代码从我的webservice(在app-engine上运行)获取我的Android客户端上的一些数据时

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

我收到此错误:

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.

我有https-support的org.restlet.ext.ssl.jar,我使用这一行添加客户端

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

这是我最接近的https://调用工作,因为我搬到了resm 2.1m4(因为我需要entityBuffering而移动)。

有什么想法吗? 我需要分享的其他信息吗?

2 个答案:

答案 0 :(得分:3)

搞定了。 将HttpClient更改为org.restlet.ext.net。

在Android上,系统会告诉您这样做是为了更改客户端

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

然而,通过这样做没有任何改变,相反,我取得了成功

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

这解决了issu(确保在构建路径中也有org.restlet.ext.ssl)。 这也解决了其他问题,例如“内部连接器错误(1002) - 调用线程在等待解除阻塞的响应时超时。”

答案 1 :(得分:0)

我曾使用kso​​ap2处理过web服务,你可以尝试使用kso​​ap2下载jar并包含在你的项目中。