电信smgp3.0发短信出现乱码
各位大侠,最近在做电信smgp协议下发短信功能,电信只提供了sp号,网上找了个smgp开发包和文档http://download.csdn.net/detail/s1351026/4301478里面有测试用例,当我在该开发包中测试(开发包编码为gbk)发送的短信能正常在手机上显示,将开发包改为utf-8发出的是乱码,因为我们系统是统一UTF-8,将开发包打成jar放入系统中跑在tomcat发送短信也是乱码,主要代码为一下:
SMGP3 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为gbk18030submit.sMsgContent =content;// sxit测试短信5555566";
submit.sReserve = "";
TSMGP_TLV tlv = new TSMGP_TLV();
tlv.b_cDestMaskFlag = true;
tlv.cDestMaskFlag = 1;
tlv.b_cFeeFlag = true;
tlv.cFeeFlag = 1;
tlv.b_cFeeMaskFlag = true;
tlv.cFeeMaskFlag = 1;
tlv.b_cMServiceID = true;
tlv.cMServiceID = 1;
tlv.b_cMsgType = true;
tlv.cMsgType = 1;
tlv.b_cNodesCount = true;
tlv.cNodesCount = 1;
tlv.b_cPid = true;
tlv.cPid = 1;
tlv.b_cPkNumber = true;
tlv.cPkNumber = 1;
tlv.b_cPkTotal = true;
tlv.cPkTotal = 1;
tlv.b_cSpDealResult = true;
tlv.cSpDealResult = 1;
tlv.b_cSpMaskFlag = true;
tlv.cSpMaskFlag = 1;
tlv.b_cSrcMaskFlag = true;
tlv.cSrcMaskFlag = 1;
tlv.b_cUdhi = true;
tlv.cUdhi = 1;
tlv.b_strDestNumberMask = true;
tlv.strDestNumberMask = "123";
tlv.b_strMsgSrc = true;
tlv.strMsgSrc = "测试TLV";
tlv.b_strFeeNumberMask = true;
tlv.strFeeNumberMask = "232";
tlv.b_strLinkId = true;
tlv.strLinkId = "";
tlv.b_strSrcNumberMask = true;
tlv.strSrcNumberMask = "4333435";
// submit.tsmgpTlv=tlv;
TSMGP_RESP resp = new TSMGP_RESP();
int submit_ret = smgp.SMGP_Submit(socketID, submit, resp);