package com.skywin.simpass.sysinterface.sms.util;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.huawei.insa2.comm.cmpp.message.CMPPDeliverMessage;
import com.huawei.insa2.comm.cmpp.message.CMPPMessage;
import com.huawei.insa2.comm.cmpp.message.CMPPSubmitMessage;
import com.huawei.insa2.comm.cmpp.message.CMPPSubmitRepMessage;
import com.huawei.insa2.util.Args;
import com.huawei.smproxy.SMProxy;
import com.skywin.simpass.sysinterface.sms.entity.SMSEntity;
public class SMSClient extends SMProxy {
private static SMSClient ins;
private SMSClient(Args args) {
super(args);
}
public static SMSClient getInstance() {
if (ins == null) {
Map<String, String> m = new HashMap<String, String>();
// 系统参数配置
m.put("host", "host");
m.put("port", "port");
m.put("source-addr", "source-addr");
m.put("shared-secret", "shared-secret");
m.put("heartbeat-interval", "30");
m.put("reconnect-interval", "30");
m.put("heartbeat-noresponseout", "5");
m.put("transaction-timeout", "10");
m.put("version", "0");
m.put("debug", "true");
ins = new SMSClient(new Args(m));
}
return ins;
}
public CMPPMessage onDeliver(CMPPDeliverMessage msg) {
String message = null;
try {
String receivedMsg = new String(msg.getMsgContent(), "UTF-8");
// System.out.println("接收到的消息:"+receivedMsg);
String receivedTelephone = msg.getSrcterminalId();
// System.out.println("接收的手机号码:"+receivedTelephone);
if ((receivedMsg.subSequence(0, 5)).equals("CSize")) {
System.out.println(receivedMsg);
} else {
message = "充值请求信息格式不对";
CMPPSubmitMessage submitMsg = new CMPPSubmitMessage(1, 1, 0, 1,
"0010", 0, "", 0, 0, 15, "950338", "02", Integer
.toString(0),
new Date(System.currentTimeMillis() + (long) 50000), // 存活期
null, "10658672", new String[] { receivedTelephone },
message.getBytes(), "");
// 发送错误信息给用户
SMSClient.getInstance().send(submitMsg);
}
} catch (Exception e) {
}
return super.onDeliver(msg);
}
public void send(CMPPSubmitMessage msg) throws Exception {
CMPPSubmitRepMessage rep = (CMPPSubmitRepMessage) super.send(msg);
// System.out.println(rep.toString());
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
SMSClient client = SMSClient.getInstance();
System.in.read();
}
}
分享到:
相关推荐
华为短信网关超完整版 CMPP SGIP SMPP 对应移动联通电信各大网关!
cmpp2.0网关短信发送DEMO(smproxy.jar) 使用华为jar包实现,只吃cmoo2.0 和 3.0。参考 博客 https://blog.csdn.net/leiliz/article/details/73810598
华为_短信API(综合网关)
华为最新短信API(综合网关) 支持 CMPP2.0 CMPP3.0 CNGP SGIP SMGP SMPP 含详细开发接口文档
华为提供的中国移动短信网关cmpp 3.0java api, 含java doc和代码样例, 代码样例修改配置参数, 可直接连接短信网关发送和接收短信.
华为短信网关平台、中兴短信网关平台,根据两大主流平台提供的接入信息封装接口,里面包含有一下文件:SMGPLoginRespMessage.java,SMGPLoginMessage.java,SGIPConnection.java,CMPP30Connection.java,CMPP30...
华为cmpp协议短信网关Delphi源码
中国移动 短信网关 包含代码 cmpp3.0协议API 和源码样例,学习移动短信网关开发好资料
华为短信api的java源码,支持cngp,cmpp2,cmpp3,smgp,sgip,smpp
1.对接华为云短信接口需要先利用composer安装Guzzle,才能请求发送短信. 2.根据文档修改对应参数即可,发送类已封装好,秩序填入短信参数,请求即可
华为云短信发送demo,
华为cmpp短信API,包含windows,java,unix说明文档,很详细。其中unix的本人亲测可以使用,不过要先仔细阅读说明文档。需要帮忙的话可以留言联系我。
华为 infoX-SMS-GW 短信网关,话单说明
联通亲情1+ 华为HG227路由DD固件!!!
生产环境测试GPON介绍及华为OLT网关注册配置流程; 生产环境测试GPON介绍及华为OLT网关注册配置流程; 生产环境测试GPON介绍及华为OLT网关注册配置流程;
短信开发文档及软件包(华为网关方式) smproxy(20040730).jar包 短消息代理(CMPP20 SMProxy)使用说明书.doc
可下载一个短信模拟网关测试。做了一个短信发送的案例,用的华为2.0,模拟服务器和客户端多次交互并且短信通知
smgp 电信短信 网关
华为USG6000E安全网关的使用手册,讲解很详细