黑莓应用程序在尝试访问服务器时卡住
我已经构建了一个 ASP.NET Web 服务,并且正在尝试从 Blackberry 访问它。我已经用多个设备和模拟器对其进行了测试,它工作正常,但只有一台 Blackberry 9000(这不是型号,我已经用另一台 Blackberry 9000 进行了测试),并且它卡住了,等待响应从服务器。访问此代码的相关部分 -
System.out.println("IN ntwk access thread, start point");
HttpConnection connection = (HttpConnection)Connector.open(serviceURL + WSNAME);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-length", Integer.toString(postData1.length));
OutputStream requestOutput = connection.openOutputStream();
requestOutput.write(postData1);
requestOutput.close();
final int responseCode = connection.getResponseCode();
if(responseCode!= HttpConnection.HTTP_OK) {
//Process the error condition
}
// Request succeeded process the data.
在 connection.getResponseCode()
之后似乎陷入困境。有什么方法可以验证这个特定设备出了什么问题吗?
谢谢,
泰贾
I've built a ASP.NET webservice and I'm trying to access it from a Blackberry. I've been testing it out with multiple devices and the simulator and it works fine, but there's just the one Blackberry 9000 (It's not the model, I've tried it out with another Blackberry 9000), and it's stuck waiting for a response from the server. Relevant section of the code that accesses this -
System.out.println("IN ntwk access thread, start point");
HttpConnection connection = (HttpConnection)Connector.open(serviceURL + WSNAME);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-length", Integer.toString(postData1.length));
OutputStream requestOutput = connection.openOutputStream();
requestOutput.write(postData1);
requestOutput.close();
final int responseCode = connection.getResponseCode();
if(responseCode!= HttpConnection.HTTP_OK) {
//Process the error condition
}
// Request succeeded process the data.
It seems to be getting stuck after connection.getResponseCode()
. Is there some way I can verify what's going wrong with this particular device?
Thanks,
Teja
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明我没有正确处理网络。它在设备中不起作用,因为我需要明确提及我希望设备使用哪个连接。不这样做将使其在模拟器中正常工作,但不能在手机本身上正常工作。
目前,我已将 ;deviceside=false 附加到连接字符串中,这使其可以使用运营商的数据服务,而无需黑莓的参与。
So it turns out I wasn't handling the network right. It wasn't working in the device because I needed to explicitly mention which connection I wanted the device to use. Not doing this will make it work fine in the simulator, but not on the phone itself.
For now, I've appended ;deviceside=false to the connection string and this makes it use the carrier's data service without Blackberry's involvement.