最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
J2me访问dotnetwerbservice
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
Post by: chinapeople @ 2003-9-21 12:51:55
1.思路:使用j2me中本身自带的HttpConnection访问webservice,调用http://localhost/RoadWebService/RoadWS.asmx/中的方法WebServiceTest,参数为param。如下:
private void connect() {
HttpConnection hc = null;
//InputStream in = null;
DataInputStream in = null;
String s="";
String url = "http://localhost/RoadWebService/RoadWS.asmx/WebServiceTest?param="+inputTextField.getString();
try {
hc = (HttpConnection)Connector.open(url);
int ch;
in = hc.openDataInputStream();
while((ch=in.read())!=-1){
s=s+(char)ch;
}
//String s = in.readUTF();
in.close();
hc.close();
mMessageItem.setText(s);
}
catch (IOException ioe) {
mMessageItem.setText(ioe.toString());
}
// mDisplay.setCurrent(mMainform);
String [] items;
//此处是对的到的字符串S进行XML解析。
items = parseUsingkXML( s );
mDisplay.setCurrent( new ItemList( items ) );
}
这时候的到的字符串流是XML格式的,如下: hello zl
使用第三方的CLDC
-
上一个: 谈谈J2ME的跨平台性
-
下一个: J2ME开发环境搭建 之 Sun WTK
相关文章
- SpringBoot测试配置属性与web启动环境解析 10-24
- vue中将el-switch值true、false改为number类型的1和0解析 10-24
- Vue中的路由配置项meta使用解读 10-24
- SpringBoot自定义bean绑定解析 10-24
- SpringBoot常用计量与bean属性校验和进制数据转换规则解析 10-24
- 工厂方法在Spring框架中的运用介绍 10-24