use of cn.b2m.eucp.sdkhttp.SDKServiceBindingStub in project portal by ixinportal.
the class SmsClientYMService method sendSms.
@Override
public String sendSms(Smsserver smsserver, String mphone, String content) {
try {
log.error("【亿美】{}", mphone + " " + content);
// 调用亿美短信接口发送短信
java.net.URL endpointURL = new java.net.URL(smsserver.getAddress());
javax.xml.rpc.Service service = null;
SDKServiceBindingStub client = new SDKServiceBindingStub(endpointURL, service);
return client.sendSMS(smsserver.getSmsKey(), smsserver.getPassword(), "", new String[] { mphone }, content, "", "utf-8", 5, 0) + "";
} catch (IOException e) {
log.error("【亿美】{}", "发送失败 " + e.toString());
}
return null;
}
use of cn.b2m.eucp.sdkhttp.SDKServiceBindingStub in project portal by ixinportal.
the class SmsSendService method sendSmsByEmay.
/**
* 调用亿美短信接口发送短信
*
* @param smsGate
* @param mobile
* @param content
* @param smsType
* @param projectId
* @return
*/
public boolean sendSmsByEmay(SmsGate smsGate, String mobile, String content, String smsType, Long projectId, String userSn, String keySn) {
boolean ret = false;
// SysUser sysUser = sqlSession.selectOne(
// "com.itrus.portal.db.SysUserMapper.selectByPrimaryKey",
// sysUserId);
// if (null == sysUser) {
// logger.error("发送失败 ,id为【" + sysUserId + "】的用户不存在");
// return false;
// }
SmsLog smsLog = new SmsLog();
smsLog.setSmsType(smsType);
smsLog.setmPhoneNum(mobile);
smsLog.setCreateTime(new Date());
smsLog.setProjectId(projectId);
// smsLog.setSysUser(sysUserId);
// 添加用户日志
UserLog userLog = new UserLog();
userLog.setHostId("未知");
String smsTypeStr = smsType;
if ("SHJJ".equals(smsType)) {
smsTypeStr = "审核拒绝";
}
userLog.setType(smsTypeStr);
userLog.setSn(userSn);
userLog.setProject(projectId);
String info = "";
int sendValue = -1;
try {
logger.debug(mobile + " " + content);
// 调用亿美短信接口发送短信
java.net.URL endpointURL = new java.net.URL(smsGate.getEmayAddress());
javax.xml.rpc.Service service = null;
SDKServiceBindingStub client = new SDKServiceBindingStub(endpointURL, service);
if (0 != regValue) {
} else {
sendValue = client.sendSMS(smsGate.getEmaySerialnum(), smsGate.getEmayPass(), "", new String[] { mobile }, content, "", "utf-8", 5, 0);
smsLog.setGateType(smsGate.getGateType());
if (0 == sendValue) {
logger.debug("发送成功");
smsLog.setSendStatus(SMS_STATUS_SUCCESS);
ret = true;
info = "手机号:" + mobile + ",发送成功\n订单号:" + keySn;
} else {
info = "手机号:" + mobile + ",发送失败.返回码:" + sendValue + "\n订单号:" + keySn;
smsLog.setSendStatus(SMS_STATUS_FAIL);
smsLog.setCommentInfo("返回信息:" + sendValue);
logger.error("发送失败 " + sendValue);
}
}
} catch (IOException e) {
info = "手机号:" + mobile + ",发送失败.返回码:" + sendValue + "\n订单号:" + keySn;
smsLog.setSendStatus(SMS_STATUS_FAIL);
smsLog.setCommentInfo("出现未知异常,请查看日志");
logger.error("发送失败 " + e.toString());
}
if (!"sendSms4three".equals(smsType)) {
sqlSession.insert("com.itrus.portal.db.SmsLogMapper.insert", smsLog);
userLog.setInfo(info);
LogUtil.userlog(sqlSession, userLog);
}
return ret;
}
use of cn.b2m.eucp.sdkhttp.SDKServiceBindingStub in project portal by ixinportal.
the class SmsSendService method sendSmsByEmayWithKeySn.
public boolean sendSmsByEmayWithKeySn(SmsGate smsGate, String mobile, String content, String smsType, Long projectId, String keySn) {
boolean ret = false;
String info = "";
int sendValue = -1;
try {
logger.debug(mobile + " " + content);
// 调用亿美短信接口发送短信
java.net.URL endpointURL = new java.net.URL(smsGate.getEmayAddress());
javax.xml.rpc.Service service = null;
SDKServiceBindingStub client = new SDKServiceBindingStub(endpointURL, service);
if (0 != regValue) {
} else {
sendValue = client.sendSMS(smsGate.getEmaySerialnum(), smsGate.getEmayPass(), "", new String[] { mobile }, content, "", "utf-8", 5, 0);
if (0 == sendValue) {
logger.debug("发送成功");
ret = true;
info = "keySn:" + keySn + ",手机号:" + mobile + ",发送成功";
} else {
info = "keySn:" + keySn + ",手机号:" + mobile + ",发送失败.返回码:" + sendValue;
logger.error("发送失败 " + sendValue);
}
}
} catch (IOException e) {
info = "keySn:" + keySn + ",手机号:" + mobile + ",发送失败.返回码:" + sendValue;
logger.error("发送失败 " + e.toString());
}
// 添加系统日志
LogUtil.syslog(sqlSession, smsType, info);
return ret;
}
use of cn.b2m.eucp.sdkhttp.SDKServiceBindingStub in project portal by ixinportal.
the class SmsSendService method smsGateTest.
// 短信网关测试
public Map<String, Object> smsGateTest(SmsGate smsGate) {
Map<String, Object> re = new HashMap<String, Object>();
re.put("retCode", false);
re.put("retMsg", "测试失败");
if (0 == smsGate.getGateType()) {
// 亿美短信网关测试
try {
// 调用亿美短信接口发送短信
java.net.URL endpointURL = new java.net.URL(smsGate.getEmayAddress());
javax.xml.rpc.Service service = null;
SDKServiceBindingStub client = new SDKServiceBindingStub(endpointURL, service);
// 判断是否需要激活序列号,regValue值0表示已经注册
regValue = 0;
double blance = 0;
if (0 == regValue) {
// 测试成功,并获取余额
blance = client.getBalance(smsGate.getEmaySerialnum(), smsGate.getEmayPass());
re.put("retCode", true);
re.put("retMsg", "测试成功,余额" + blance + "元");
} else {
logger.warn("regValue=" + regValue);
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
regValue = 0;
int blance = 0;
if (0 == regValue) {
// 测试成功,并获取余额
// 调用未来短信帐户查询余额
String str = "{" + smsClientService.balanceQuery(smsGate.getGateAddress(), smsGate.getAccountPass(), smsGate.getAccountName()) + "}";
JSONObject jsonObject = JSONObject.parseObject(str);
blance = (int) jsonObject.get("sms_balance");
re.put("retCode", true);
re.put("retMsg", "测试成功,余额" + blance + "条");
} else {
logger.warn("regValue=" + regValue);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return re;
}
Aggregations