//byte data_coding = 1;
byte data_coding = 15; //15为GB2312
byte sm_len = 120;
String ss = args[1];
try{
short_msg = ss.getBytes("GB2312");
ss = new String(short_msg);
}catch(Exception e){
}
System.out.println(short_msg.length);
cmppe_result cr = new cmppe_result();
cmppe_deliver_result rs = new cmppe_deliver_result();
try{
conn_desc con = new conn_desc();
System.out.println("connecting...");
p.cmpp_connect_to_ismg("111.111.111.111",7890,con); //登
陆信息隐藏,SORRY哈
System.out.println("ICP_ID:" + "******" + " ICP_AUTH:" + "**");
p.cmpp_login(con,"*****","****",(byte)2,0x12,*******);
t.readPaME(con);
sub.set_icpid(icp_id );
sub.set_svctype(svc_type);
sub.set_feetype(fee_type );
sub.set_infofee(info_fee);
sub.set_protoid(proto_id);
sub.set_msgmode(msg_mode );
sub.set_priority(priority );
sub.set_validate(validate);
sub.set_schedule(schedule );
sub.set_feeutype(fee_utype);
sub.set_feeuser(fee_user);
sub.set_srcaddr(src_addr );
sub.set_dstaddr(dst_addr );
sub.set_ducount(du_count);
sub.set_msg(data_coding,short_msg.length,short_msg );
p.cmpp_submit(con,sub);
t.readPaME(con);
p.cmpp_active_test(con);
t.readPaME(con);
p.cmpp_logout(con);
t.readPaME(con);
}catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
System.out.println("have a exception");
try{
System.in.read();
}catch(Exception e1)
{
}
return;
}
}
public static byte toHex(char c){
switch(c){
case ?':
return 0x31;
case ?':
return 0x32;
case ?':
return 0x33;
case ?':
return 0x34;
case ?':
return 0x35;
case ?':
return 0x36;
case ?':
return 0x37;
case ?':
return 0x38;
case ?':
return 0x39;
case ?':
return 0x30;
default: break;
}
return 0x0;
}
}
如果您运行该程序得到该结果,就说明正常。
7 connecting... ICP_ID:111111 ICP_AUTH:1111 login_type:2 CMPP_VERSION:18 cr.pack_id=-2147483647 CMPP.CMPPE_LOGIN_RESP:login resp: STAT = 0 cr.pack_id=5 CMPP.CMPPE_DELIVER:deliver: STAT = 0 cr.pack_id=-2147483644 CMPP.CMPPE_SUBMIT_RESP cr.pack_id=-2147483640 CMPP.CMPPE_ACTIVE_RESP:active resp: STAT 0 |
主要看stat是0就行了,其它的是我的调试信息,首行7表示短信长度
查看本文来源