站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题NOKIA3230 使用基于HTTP协议的应用程序,总是提示报错:SymbianOS Error=-5120 (电脑上没有问题,手机就有问题)

NOKIA3230 使用基于HTTP协议的应用程序,总是提示报错:SymbianOS Error=-5120 (电脑上没有问题,手机就有问题)

摘要: NOKIA3230 使用基于HTTP协议的应用程序,总是提示报错:SymbianOS Error=-5120 (电脑上没有问题,手机就有问题)


我的手机是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());

}
}


beget是在哪里定义的?


使用cmnet,或者使用cmwap并设置代理


我觉得楼主一定没有在真机上试过,在真机上这样根本不行


我的确是从来没有在真机器上试过,还望大家多指教。
本人以前搞ERP的,半路出家想学J2ME,这不刚开始就搞不下去了。
正如liujun999999(神仙、妖怪、谢谢) 所说,我的手机设置了CMWAP代理。
请教楼上jia525() ,我该怎么办?



关注ing


private void submitForResult(Task t) throws IOException {
HttpsConnection conn = null;
DataOutputStream dos = null;
DataInputStream dis = null;

try {
//String CMCC_PROXY = "http://10.0.0.172:80/"; //这个是中国移动的代理
//conn = (HttpsConnection)Connector.open(CMCC_PROXY + "Bank/do");
//conn.setRequestProperty("X-Online-Host", "security.sunnitech.com");
conn = (HttpsConnection)Connector.open(url);
} catch(IOException e1) {
throw (new IOException("网络出错!" + e1.toString()));
}

try {
conn.setRequestMethod(HttpsConnection.POST);
//conn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
//conn.setRequestProperty("Content-Language", "en-US");
//conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
dos = new DataOutputStream(conn.openOutputStream());
dos.writeInt(getTaskType());
t.serialize(dos);

int status = conn.getResponseCode();

if(status != HttpsConnection.HTTP_OK) {
throw (new Exception("getResponseCode error!"));
} else {
dis = new DataInputStream(conn.openInputStream());

if(dis.readInt() != getTaskType()) {
throw (new Exception("getTaskType error!"));
} else {
t.deserialize(dis);
}
}
} catch(Exception e) {
throw (new IOException("网络出错了!" + e.toString()));
} finally {
if(dis != null) {
dis.close();
}

if(dos != null) {
dos.close();
}

if(conn != null) {
conn.close();
}
}
}

象上面这样设置代理


String CMCC_PROXY = "http://10.0.0.172:80/"; //这个是中国移动的代理
conn = (HttpsConnection)Connector.open(CMCC_PROXY + "Bank/do");
conn.setRequestProperty("X-Online-Host", "security.sunnitech.com");


up


o


3230 不支持CMNET?

注意zyg158((DD)OTP) 用的是post方法,不要用get




↑返回目录
前一篇: j2me是否能操作window的Active组件?我想用j2me来二次开发Mapx mobile 5
后一篇: 一点想法,欢迎大家评述!!!