普通的wappush消息走ismg传递示例代码


    /**
     * 一个扩展包wappush包是这么构成的
     * WDP + WSP + SI/SL
     * 如果长度超常(短信一个包的Content不要超过140)
     * 就要分解成
     * WDP1 + (WSP+SI/SL)的part 1
     * WDP2 + (WSP+SI/SL)的part 2
     * ...
     * WDPN + (WSP+SI/SL)的part N
     * 如单包
     * WDP: 06 05 04 0B 84 23 F0
     * WSP: ...
     * SI/SL:...
     * 双包是
     * 第1包
     * WDP: 0B 05 04 0B 84 23 F0 00 03 01 02 01
     * Part1: ...
     * // 00 - UDH IE Tag
     * // 03 - UDH SAR IE Length
     * // 01 - Reference
     * // 02 - Total Packet
     * // 01 - Current Packet
     * 第2包
     * WDP: 0B 05 04 0B 84 23 F0 00 03 01 02 02
     * Part2:...
     *
     *
     */
 
 public static byte[] genPacketX(String title, String url)
 {
        byte[] Title = null;
        try {
            Title = title.getBytes("UTF-8");
        } catch (java.io.UnsupportedEncodingException e) {
            Title = title.getBytes();
        }
        byte[] Url = null;   
        if(url.toLowerCase().startsWith("http://") )
            url=url.substring(7);
        Url = url.getBytes();
        byte[] result = new byte[35 + Title.length + Url.length];
        int i = 0;
  //UDH//7 bytes WDP header
        result[i++] = 0x06;
        result[i++] = 0x05;
        result[i++] = 0x04;
        result[i++] = 0x0b;
        result[i++] = (byte) 0x84;
        result[i++] = 0x23;
        result[i++] = (byte) 0xf0;
        //PDU
        result[i++] = 0x01; // push-id
        result[i++] = 0x06; // pdu = push
        result[i++] = 0x0a; // headlen=10
        result[i++] = 0x03; // cert ??
        result[i++] = (byte) 0xae; // application/vnd.wap.sic
        result[i++] = (byte) 0x81; // charset
        result[i++] = (byte) 0xea; // utf-8
        result[i++] = (byte) 0xaf;
        result[i++] = (byte) 0x82;
        result[i++] = (byte) 0x8d; //
        result[i++] = (byte) 0xae;
        result[i++] = (byte) (Url.length + 159);
        result[i++] = (byte) 0x87;
        //SI part
        result[i++] = 0x02;
        result[i++] = 0x05; //-//WAPFORUM//DTD SI 1.0//EN
        result[i++] = 0x6A; //UTF-8
        result[i++] = 0x00; //字符串结束
        result[i++] = 0x45; //<si>
        result[i++] = (byte) 0xC6; //<indication
        result[i++] = 0x08; //<action=signal-high>
        result[i++] = 0x0C; //href="http://
        result[i++] = 0x03; //字符串开始
        for (int j = 0; j < Url.length;) {
            result[i++] = Url[j++];
        } //实际地址
        result[i++] = 0x00; //字符串结束
        // result[i++] = 0x0A; //created=
        //result[i++] = (byte)0xC3; //'时间
        // result[i++] = 0x07; //时间字节数
        //result[i++] = ; //YYYYMMDDHHMMSSstartTime
        // result[i++] = 0x10; //si_expires=
        // result[i++] = (byte)0xC3; //时间
        // result[i++] = 0x07; //时间字节数
        //result[i++] = ; //YYYYMMDDHHMMSS
        result[i++] = 0x01; //>
        result[i++] = 0x03; //字符串开始endTime
        for (int j = 0; j < Title.length;) {
            result[i++] = Title[j++];
        }
        result[i++] = 0x00; //字符串结束
        result[i++] = 0x01; //</indication>"
        result[i++] = 0x01; //'</si>
  return result;
 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值