草庐IT

Android ReSTLet HTTPS

coder 2023-12-15 原文

当尝试使用此代码从我的 web 服务(在应用程序引擎上运行)获取我的 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 支持的 org.reSTLet.ext.ssl.jar,我正在使用这一行来添加客户端

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

这是自从我升级到 reSTLet 2.1m4(移动是因为我需要 entityBuffering..)以来我最接近 https://调用工作的一次。

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

最佳答案

开始工作了。 将 HttpClient 更改为 org.reSTLet.ext.net。

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

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

但是这样做没有任何改变,相反,我成功了

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

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

关于Android ReSTLet HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6068303/

有关Android ReSTLet HTTPS的更多相关文章

随机推荐