在黑莓中发送带有凭据的 HTTP 请求
我正在尝试在黑莓中使用网络凭据调用 HTTP 请求。我已经在 Java、Android 上实现了,它工作正常,但在黑莓上不起作用。以下步骤是我在黑莓中完成的。
为了设置网络凭据,我添加了以下三个 jar。
- commons-codec-1.6.jar
- commons-httpclient-3.0.1.jar
- commons-logging-1.1.1.jar
添加此 jar 文件位于黑莓项目中。
以下示例代码在 Core Java 中运行良好。
try{ HttpClient client = new HttpClient(); GetMethod get = new GetMethod("http://www.google.com"); get.setDoAuthentication( true ); try { int status = client.executeMethod( get ); System.out.println(status + "\n" + get.getResponseBodyAsString()); } finally { get.releaseConnection(); } }catch(Exception e){ System.out.println("Error:>>>>>>"+e); }
现在代码上没有错误,但每当尝试单击应用程序图标时都会出现错误,例如“启动 appName 时出错:未找到模块‘commons-httpclient-3.0.1’”
任何人都可以建议这个错误是什么意思。
I am trying to call HTTP request with network credential in blackberry. i have already implement on Java, Android it's working fine but not working on blackberry. Following step i have done in blackberry.
For set Network credential i have added three following jar.
- commons-codec-1.6.jar
- commons-httpclient-3.0.1.jar
- commons-logging-1.1.1.jar
add this jar files are in blackberry project.
Following sample Code that work fine in Core Java.
try{ HttpClient client = new HttpClient(); GetMethod get = new GetMethod("http://www.google.com"); get.setDoAuthentication( true ); try { int status = client.executeMethod( get ); System.out.println(status + "\n" + get.getResponseBodyAsString()); } finally { get.releaseConnection(); } }catch(Exception e){ System.out.println("Error:>>>>>>"+e); }
Now there are not error on code but whenever try to click on application icon error face like "error starting appName: Module 'commons-httpclient-3.0.1' not found"
Can any one suggest what's this error say.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
BB 不支持
HttpClient
。但它确实支持J2ME的HttpConnection
并且与HttpClient
非常相似,因此您可以轻松地使用它进行调整。下面是一些示例代码,可帮助您入门:这是一篇很好的文章,可以帮助您更好地学习理解。
BB does not support
HttpClient
. But it does support J2ME'sHttpConnection
and is quite similar toHttpClient
, so you can easily adjust with it. Here's some sample code to get you started:This is a good article for beter understanding.