一、定义http服务向服务器发送并接受数据
(1)(连接工具类)
public class HttpURLConn {
// 发送带参数的Post请求,得到返回的xml字符串
public static String sendPost(String url, String param) throws Exception {
String result = "";
System.out.println("connent_center!");
System.out.println("url="+url);
try {
URL httpurl = new URL(url);
HttpURLConnection httpConn = (HttpURLConnection) httpurl
.openConnection();
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
// httpConn.setRequestMethod("POST");
PrintWriter out = new PrintWriter(httpConn.getOutputStream());
out.print(URLEncoder.encode(param,"GBK"));
out.print(param);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String lin