json-rpc请求:
/** * @param jsonArgument * @return */ public static String get_data(String jsonArgument ) { try { URL httpUrl = new URL(PropKit.get("zabbix.url")); HttpURLConnection conn = (HttpURLConnection) httpUrl.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "application/json-rpc"); // 表单参数 StringBuffer params = new StringBuffer(); params.append(jsonArgument); byte[] bypes = params.toString().getBytes(); conn.getOutputStream().write(bypes);// 输入参数 //返回 if(conn.getInputStream()!=null){ BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String result = reader.readLine(); reader.close(); return result; }else{ return null; } } catch (Exception e) { logger.error("DATA:"+jsonArgument, e); //e.printStackTrace(); } return null; }