NOKIA3230 使用基于HTTP协议的应用程序,总是提示报错:SymbianOS Error=-5120 (电脑上没有问题,手机就有问题)
深圳李春雷 2006-05-27 11:30:56 我的手机是NOKIA3230
自己开发了一个基于HTTP协议的J2ME应用程序,功能很简单,就是打开一个网页。
可是总是提示报错:SymbianOS Error=-5120 :网络:服务器未找到。
听说是因为我的手机不支持CMNET,我就设置了CMWAP的代理,可还是没有解决。
难道我非得换成全球通吗?
请问各位这是为什么?
很着急啊,先谢谢了。
lcl@linhangsoft.com
代码摘录如下:
public void HTTPGet(String urlstring) throws IOException {
HttpConnection hc = null;
InputStream is = null;
OutputStream os = null;
StringBuffer buf = new StringBuffer();
TextBox t = null;
try {
hc = (HttpConnection) Connector.open(urlstring);
//Connector.READ_WRITE
hc.setRequestMethod(HttpConnection.GET);
//设置属性
//hc.setRequestProperty("CONTENT-TYPE", "application/x-www-form-Agent");
hc.setRequestProperty("User-Agent",
"Profile/MIDP-1.0 Configuration/CLDC-1.0");
//hc.setRequestProperty("Content-Language", "en-CA");
//hc.setRequestProperty("Connection","Keep-Alive");
is = hc.openDataInputStream();
int ch;
while ( (ch = is.read()) != -1) {
buf.append( (char) ch);
}
System.out.println("返回结果:" + buf.toString());
t = new TextBox("post testpage", buf.toString(), 1024, 0);
t.addCommand(back);
t.setCommandListener(this);
}
finally {
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
if (hc != null) {
hc.close();
}
}
display.setCurrent(t);
}
......
public void run() {
try {
if (beget = false) {
HTTPPost(replace(urlstrpost, " ", "%20"));
}
else {
HTTPPost(replace(
//"http://127.0.0.1:8090/LH/Test.html",
"http://www.lhsoft.com.cn/Test.html",
" ", "%20"));
}
}
catch (IOException ex) {
errorform.append("最后报错:" + ex.getMessage());
display.setCurrent(errorform);
ex.printStackTrace();
System.out.println("最后的问题:" + ex.getMessage());
}
}