最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
J2me访问dotnetwerbservice
时间:2022-07-02 17:43:21 编辑:袖梨 来源:一聚教程网
J2me访问dotnetwerbservice[分享]
Post by: chinapeople @ 2003-9-21 12:51:55
1.思路:使用j2me中本身自带的HttpConnection访问webservice,调用http://loca*lh*o*st/RoadWebService/RoadWS.asmx/中的方法WebServiceTest,参数为param。如下:
private void connect() {
HttpConnection hc = null;
//InputStream in = null;
DataInputStream in = null;
String s="";
String url = "http://l*ocalho**st/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
Post by: chinapeople @ 2003-9-21 12:51:55
1.思路:使用j2me中本身自带的HttpConnection访问webservice,调用http://loca*lh*o*st/RoadWebService/RoadWS.asmx/中的方法WebServiceTest,参数为param。如下:
private void connect() {
HttpConnection hc = null;
//InputStream in = null;
DataInputStream in = null;
String s="";
String url = "http://l*ocalho**st/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
相关文章
- myfreemp3音乐网站最新网址链接-myfreemp3在线音乐免费地址入口分享 11-04
- myfreemp3音乐网站网址链接-myfreemp3在线音乐网站地址入口 11-04
- 非主流时尚爱情图片 11-03
- 拼多多商家登录-拼多多商家网页版登录入口 11-03
- DeepSeek-网页版官方入口 11-03
- qq邮箱网页版登录入口-qq邮箱官网直接访问地址 11-03