package com.huawei.eie.api.sm;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
/**
*
* <p>Title: mas</p>
*
* <p>Description: <br>
* smproxy 的示例测试类,覆盖了所有的测试接口。<br>
* </p>
*
* <p>Copyright: Copyright (c) 2007</p>
* <br><br><br>
*
* <br><br><br>
* <p>Company: www.huawei.com</p>
*
* @author www.huawei.com
* @version 1.0
*/
public class DBSMProxyTest
{
public DBSMProxyTest()
{
}
/**
* 演示如何使用dbsmproxy 代码样例。
* @throws Exception
*/
public static final void testSendMessage()
throws Exception
{
DBSMProxy smproxy = createProxy();
testSend(smproxy,100); //发送消息测试接口。
testGetReceivedSm(smproxy,10); //接收消息测试接口。
testQuerysmResult(smproxy);//查询消息测试接口。
//退出登陆。
smproxy.logout();
//销毁连接。
smproxy.destroy();
}
/**
* 演示如何产生一个proxy连接的代码样例
* @return DBSMProxy
* @throws Exception
*/
public static final DBSMProxy createProxy()
throws Exception
{
DBSMProxy smproxy = new DBSMProxy();
//"./apiconf/smApiConf.xml"
try
{
smproxy.initConn();//自动查找配置文件的方式初始化,参见上面函数说明。
}
catch (Exception ex)
{
try
{
smproxy.initConn("./apiconf/smApiConf.xml");
}
catch (Exception exx)
{
Map paras = new HashMap();
//企业信息机短信接口db的url。
paras.put("url","jdbc:microsoft:sqlserver://10.71.99.70:1433;DatabaseName=db_customsms");
//企业信息机短信接口db登陆用户名。
paras.put("user","customsms");
//企业信息机短信接口db登陆的密码。
paras.put("password","123456");
//以下示例提供了3种初始化连接的方法。
smproxy.initConn(paras);//通过上面设定的参数初始化。
}
}
//手动查找配置文件的方式,参见上面函数说明。
// smproxy.initConn("./apiconf/smapiconf.xml");
//登陆企业信息机mas短信应用接口,业务登陆用户名、业务登陆密码。
try
{
smproxy.login("admin", "0");
}
catch (Exception ex)
{
ex.printStackTrace();
smproxy.login("admin","Mas12345*");
}
return smproxy;
}
/**
* 查询上行消息代码样例。
* @param smproxy DBSMProxy
* @param count int
* @throws Exception
*/
public static final void testGetReceivedSm(DBSMProxy smproxy, int count)
throws Exception
{
//如下按照多种查询条件获取短信查询情况,做代码演示。
SmReceiveBean[] beans =
smproxy.getReceivedSms(count
, new java.util.Date(System.currentTimeMillis() - 86400000)
, new java.util.Date(System.currentTimeMillis()),"xxxxxxxxxxxxxxxxx","");
System.out.println("get received sms in a day where sp number likes \'xxxxxxx\',max count is"+
count+",sms count:" + beans.length);
beans = smproxy.getReceivedSms(count
, new java.util.Date(System.currentTimeMillis() - 86400000)
, new java.util.Date(System.currentTimeMillis()),null,"xxxxxxxxxxx");
System.out.println("get received sms in a day where telno likes \'13\',max count is"+
count+",sms count:" + beans.length);
beans = smproxy.getReceivedSms(-1, null
, null
, null,null);
System.out.println("get all received sms,sms count is:" + beans.length);
}
/**
* 查询消息发送结果,代码样例。
* @param smproxy DBSMProxy
* @throws Exception
*/
public static final void testQuerysmResult(DBSMProxy smproxy)
throws Exception
{
// System.out.println(">>>>>>>>>>::::::::::::");
//构造查询条件,入口参数详细说明参见上面函数说明。
SmSendResultBean[] beans =
smproxy.querySmsResult(1
, new java.util.Date(System.currentTimeMillis() - 864000)
, new java.util.Date(System.currentTimeMillis())
,"xxxxxxxxx","");
for (SmSendResultBean bean:beans)
{
System.out.println("bean:"+bean.getSmMsgContent());
}
}
/**
* 发送测试代码样例。
* @param smproxy DBSMProxy
* @param count int
* @throws Exception
*/
public static final void testSend(DBSMProxy smproxy, int count)
throws Exception
{
SmSendBean bean = new SmSendBean();
ArrayList<String> arrs = new ArrayList();
//构造多个手机号码,目的地址。
for (int index = 0; index < count; index++)
{
arrs.add("1380000" + index);
}
String[] addrs = new String[arrs.size()];
arrs.toArray(addrs);
bean.setSmDestAddrs(addrs);
//构造消息内容。
bean.setSmMsgContent("http://www.126.com,sms content test info...~!@#$%^&*()_+|.中文测试'sdfadsfa''."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
// +"sms content test info...~!@#$%^&*()_+|.\u0E01\u0E48\u0E32\u0E2B\u0E14\u0E1F\u0E2B\u0E01\u0E44."
);
long firstTime = System.currentTimeMillis();
//发送出去。
int[] ret = null;
int randomInt =(int) (Math.random()*10);
bean.setPriority((int) (randomInt*1.0/2.5));
if (randomInt >= 5)
{
bean.setSendType(bean.SMSEND_TYPE_WAPPUSH);
}
else
{
bean.setSendType(bean.SMSEND_TYPE_TEXT);
}
if (Math.random()*10 >= 5)
{
ret = smproxy.sendSm(bean);
}
else
{
int ret00 = smproxy.sendMultiSm(bean);
ret = new int[]
{ret00};
}
long lastTime = System.currentTimeMillis();
System.out.println("======================================");
System.out.println(" inserted:" + count + " records,consumed " + (lastTime
- firstTime) + " ms");
System.out.println(" avg Speed:" + (count) * 1000.0 / (lastTime - firstTime));
System.out.println("======================================");
System.out.print("returned sm_id(s):");
for (int index = 0; index < ret.length; index++)
{
System.out.print(" " + ret[index]);
}
System.out.println("");
}
/**
* 测试方法主入口。
*
* @param args String[]
* @throws Exception
*/
public static void main(String[] args)
throws Exception
{
testSendMessage();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
javaapi.rar_Javaapi _SMAPIConfig.jar_mas短信_smapiconf
共59个文件
html:49个
bat:2个
db:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 182 浏览量
2022-09-23
12:10:07
上传
评论
收藏 4.94MB RAR 举报
温馨提示
中国移动短信MAS系统开发接口API(JAVAapi)
资源推荐
资源详情
资源评论
收起资源包目录
javaapi.rar (59个子文件)
javaapi
smApiConf.xml 4KB
EIESmProxyApi.jar 2.58MB
DBSMProxy API.zip 2.49MB
build.bat 244B
javadoc
package-list 23B
deprecated-list.html 5KB
help-doc.html 8KB
allclasses-frame.html 1KB
index.html 1KB
com
huawei
eie
api
sm
package-summary.html 7KB
DBSMProxyTest.html 15KB
package-frame.html 1KB
DBSMProxy.html 30KB
class-use
DBSMProxyTest.html 6KB
DBSMProxy.html 9KB
SmSendBean.html 8KB
SmSendResultBean.html 7KB
SmReceiveBean.html 7KB
SmSendBean.html 44KB
package-tree.html 6KB
imp
package-summary.html 8KB
package-frame.html 1KB
DBSqlConstants.html 14KB
class-use
DBSqlConstants.html 6KB
SmApiConfig.html 6KB
SmOperation.html 8KB
DBPoolConn.html 10KB
UserInfoBean.html 11KB
package-tree.html 7KB
SmApiConfig.html 28KB
SmOperation.html 25KB
DBPoolConn.html 14KB
UserInfoBean.html 13KB
package-use.html 9KB
SmSendResultBean.html 39KB
package-use.html 7KB
SmReceiveBean.html 32KB
allclasses-noframe.html 1KB
resources
inherit.gif 57B
Thumbs.db 3KB
stylesheet.css 1KB
constant-values.html 8KB
index-files
index-10.html 33KB
index-7.html 6KB
index-11.html 7KB
index-1.html 7KB
index-8.html 6KB
index-14.html 7KB
index-9.html 6KB
index-6.html 6KB
index-5.html 7KB
index-3.html 7KB
index-2.html 6KB
index-13.html 8KB
index-4.html 17KB
index-12.html 39KB
overview-tree.html 6KB
demo
DBSMProxyTest.java 8KB
runDBSMProxyTester.bat 74B
共 59 条
- 1
资源评论
钱亚锋
- 粉丝: 88
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功