public Object sendMessage(String content, String url) throws IOException
{
Object rsObj = null;
long start = System.currentTimeMillis();
BufferedReader r = null;
String rs = "";
try {
URL u = new URL(url);
URLConnection uc = u.openConnection();
uc.setRequestProperty("Connection", "close");
uc.setConnectTimeout(timeOut);
uc.setDoOutput(true);
uc.getOutputStream().write(content.getBytes("utf-8"));
r = new BufferedReader(new InputStreamReader(uc.getInputStream(),
"utf-8"));
String line;
StringBuffer buf = new StringBuffer();
int i = 0;
while ((line = r.readLine()) != null) {
buf.append(line);
}
rs = buf.toString();
rsObj = this.getResult(rs);
} catch (IOException e) {
// TODO: handle exception
String errMsg = "接口异常==sendMessage("+content+","+url+")";
log.error(errMsg);
throw e;
} finally {
try {
if (r != null)
r.close();
} catch (IOException ex) {
// ignore
throw ex;
}
}
log.debug("remote time is : " + (System.currentTimeMillis() - start));
return rsObj;
}