近来公司要做Android应用,但是数据是调用的webService。
不知道各位有没有关于怎么写Android的webService的文章和帖子。
写的太简单是不是很lower?
------解决方案--------------------
没什么的,就用httpclient请求服务器的Webservice
------解决方案--------------------
参考
/**
* a http request with given url
* @param strUrl the url you want to request
* @return
*/
public static String request(String strUrl){
logger.debug(CommonHTTPRequest.class.getName() + ", request url is : " + strUrl);
String userHome = System.getProperty("user.home");
if(userHome.contains("eacfgjl")){
useProxy = true;
}
if(useProxy){
initProxy();
}
URL url = null;
String result = "";
HttpURLConnection urlConn = null;
InputStreamReader in = null;
try {
url = new URL(strUrl);
urlConn = (HttpURLConnection) url.openConnection();
in = new InputStreamReader(urlConn.getInputStream());
BufferedReader br = new BufferedReader(in);
String readerLine = null;
while((readerLine=br.readLine())!=null){
result += readerLine;
}
in.close();
urlConn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
logger.error(ExceptionUtil.getTrace(e));
} catch (IOException e) {
e.printStackTrace();
logger.error(ExceptionUtil.getTrace(e));
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
logger.error(ExceptionUtil.getTrace(e));
}
urlConn.disconnect();
}
return result;
}
------解决方案--------------------
http://blog.csdn.net/baiyuliang2013/article/details/21979037