各位大侠,最近在做电信smgp协议下发短信功能,电信只提供了sp号,网上找了个smgp开发包和文档里面有测试用例,当我在该开发包中测试(开发包编码为gbk)发送的短信能正常在手机上显示,将开发包改为utf-8发出的是乱码,因为我们系统是统一UTF-8,将开发包打成jar放入系统中跑在tomcat发送短信也是乱码,主要代码为一下:
Java codeSMGP3 smgp = new SMGP3();
int socketID=smgp.SMGP_Connect("124.126.119.17",8890, "test",
"test",(byte)0);// 连接正常
if (socketID > 0) {
int test_ret = smgp.SMGPActiveTest(socketID);
if (test_ret == 0) {
TSMGP_SUBMIT submit = new TSMGP_SUBMIT();
submit.cMsgType = 6;
submit.cNeedReport = 1;
submit.cPriority = 0;
submit.sServiceID = "PC2P";
submit.sFeeType = "00";
submit.sFeeCode = "0";
submit.sFixedFee = "0";
submit.sValidTime = "";
submit.sAtTime = "";
submit.sSrcTermID = "106590290015";
submit.sChargeTermID = "106590290015";
submit.sDestTermID = "15332319099"
submit.ucMsgFormat = 15; // 设置消息体编码格式 8:ucs2,15为gbk18030 submit.sMsgContent =content;// sxit测试短信5555566";
submit.sReserve = "";
TSMGP_TLV tlv = new TSMGP_TLV();