我尝试从使用 JAX-WS、WSDL 构建的 Web 服务获取数据,并且我想在 Android ListView 中实现。
这是我在 Netbeans 上构建的 Web 服务中的代码。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package in.figures.on.mobile;
import db.koneksi.dbKoneksi;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import org.json.simple.JSONValue;
/**
*
* @author Setyadi
*/
@WebService()
public class AksesData {
/**
* Web service operation
*/
@WebMethod(operationName = "Lokasiku")
public String Lokasiku(
@WebParam(name = "lon") String lon,
@WebParam(name = "lat") String lat) {
//TODO write your implementation code here:
dbKoneksi con = new dbKoneksi();
Statement statement;
String sql = "SELECT desa "
+ "FROM dki "
+ "WHERE ST_Within(ST_SetSRID(ST_MakePoint("+lon+","+lat+"),0),geom);";
ResultSet hasil;
String desa = null;
try{
statement = con.getConnection().createStatement();
hasil = statement.executeQuery(sql);
hasil.next();
desa = hasil.getString(1);
}
catch(Exception e){
desa = "desa_thegagals";
}
finally{
}
if (con != null) {
return desa;
}
else {
return "lokasiku_thegagals";
}
}
/**
* Web service operation
*/
@WebMethod(operationName = "Kategori")
public String Kategori() {
//TODO write your implementation code here:
dbKoneksi con = new dbKoneksi();
Statement statement;
Properties properties;
List list = new ArrayList();
String sql = "SELECT kategori FROM kategori ";
ResultSet hasil;
String kategori = null;
try{
statement = con.getConnection().createStatement();
hasil = statement.executeQuery(sql);
while (hasil.next()) {
properties = new Properties();
properties.put("kategori", hasil.getString(1));
list.add(properties);
}
kategori = JSONValue.toJSONString(list);
}
catch(Exception e){
}
return kategori;
}
}
有没有人想帮助我,至少给我一个关于这个的教程。提前致谢