/**
* post
* 发送短信消息
* @return
*/
public String sendMsg() throws Exception{
String result = "";
System.out.println("接收参数--"+model);
try {
org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();
org.apache.commons.httpclient.methods.PostMethod httpget = new org.apache.commons.httpclient.methods.PostMethod(
"https://smsapi.ums86.com:9600/sms/Api/Send.do");
NameValuePair[] param = {
new NameValuePair("SpCode",model.getSpCode()), //企业编码
new NameValuePair("LoginName",model.getLoginName()), //用户名
new NameValuePair("Password",model.getPassword()), //密码
new NameValuePair("MessageContent",model.getMessageContent()),//短信内容
new NameValuePair("UserNumber",model.getUserNumber()), //手机号
new NameValuePair("SerialNumber",model.getSerialNumber()), //流水号
new NameValuePair("ScheduleTime",model.getScheduleTime()) , //预约发送时间
new NameValuePair("ExtendAccessNum",model.getExtendAccessNum()), //接入号扩展号
new NameValuePair("f",model.getF()) //接入号扩展号
};
httpget.setRequestBody(param);
httpget.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
httpget.getParams().setContentCharset("GBK");
// url的连接等待超时时间设置
client.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
// 读取数据超时时间设置
client.getHttpConnectionManager().getParams().setSoTimeout(30000);
client.executeMethod(httpget);
result = URLDecoder.decode(httpget.getResponseBodyAsString(),"UTF-8");
if (result != null) {
result = result.trim();
}
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println(result);
this.outJsonStrResult(result);
return NONE;
}