首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动应用 >

(急)mm7怎样发送smil格式的彩信解决方案

2012-02-08 
(急)mm7怎样发送smil格式的彩信请大家帮帮忙,mm7协议怎样发送带smil格式的彩信,代码如下:Java codepublic

(急)mm7怎样发送smil格式的彩信
请大家帮帮忙,mm7协议怎样发送带smil格式的彩信,代码如下:

Java code
public void submitSmil2(MMessageWrapper wapper) {        System.out.println(":::::::用mm7协议发送smil内容彩信");        LogHelper.debug(":::::::用mm7协议发送smil内容彩信");        MMessageContent content = wapper.getContent();        MM7SubmitReq submit = new MM7SubmitReq();        submit.setTransactionID("" + SequnceNumber.getSequnceID());        submit.setVASPID(Constants.vaspId);        submit.setVASID(Constants.vasId);        String to = wapper.getDesTermId();        submit.addTo(to);        String submitId = content.getSubmitId();        submit.setServiceCode(submitId);        String srcTermId = content.getSrcTermId();        submit.setSenderAddress(replaceSrc(srcTermId, Constants.vasId,                        submitId));        submit.setSubject(content.getSubject());        submit.setChargedParty((byte) 4); // 计费方式0:Sender、1:Recipients、2:Both、3:Neither、4:ThirdParty        submit.setChargedPartyID(wapper.getFeeTermId()); // 计费方        submit.setDeliveryReport(true);        submit.setReadReply(true);        submit.setPriority((byte) 1);        submit.setLinkedID(wapper.getLinkID());        MMContent mmcontent = new MMContent();        mmcontent.setContentType(MMConstants.ContentType.MULTIPART_RELATED);        ArrayList atts = content.getAttachments();//smil、图片、文字、声音内容        for (int i = 0; i < atts.size(); i++) {            Attachment att = (Attachment) atts.get(i);            if (att != null) {                if (att.getBinary() == null || att.getBinary().length == 0) {                    System.out.println("内容有空");                    continue;                }                byte[] buf = att.getBinary();                MMContent mmc = null;                String ct = att.getContentType();                if ("application/smil".equalsIgnoreCase(ct)) {                    System.out.println("application/smil类型");                    try {                        String s = new String(buf, "GB2312");                        mmc = MMContent.createFromBytes(s.getBytes("UTF-8"));                    } catch (UnsupportedEncodingException e) {                        e.printStackTrace();                    }                    mmc.setContentType(MMConstants.ContentType.SMIL);                    mmc.setContentID(att.getContentId());                    mmc.setContentLocation(att.getContentLocation());                    mmc.setCharset("UTF-8");                    mmcontent.setPresentionContent(mmc);                    continue;                }                if ("text/plain".equalsIgnoreCase(ct)) {                    System.out.println("text/plainl类型");                    try {                        String s = new String(buf, "GB2312");                        mmc = MMContent.createFromBytes(s.getBytes("UTF-8"));                    } catch (UnsupportedEncodingException ex1) {                        ex1.printStackTrace();                    }                    System.out.println("MMContent setCharset UTF-8");                    mmc.setCharset("UTF-8");                } else {                    System.out.println("不是text/plain类型 ");                    mmc = MMContent.createFromBytes(buf);                }                if (mmc != null) {                    mmc.setContentType(ct);                    mmc.setContentID(att.getContentId());                    mmc.setContentLocation(att.getContentLocation());                }                mmcontent.addSubContent(mmc);            }        }        submit.setContent(mmcontent);        try {            MM7Sender mm7Sender = new MM7Sender(mm7Config);            MM7RSRes rsRes = mm7Sender.send(submit);            String statusText = rsRes.getStatusText();            if (rsRes instanceof MM7SubmitRes) {                MM7SubmitRes submitRes = (MM7SubmitRes) rsRes;                wapper.setMsgID(submitRes.getMessageID());            } else {                System.out.println("MM7RSRes toString(): " + rsRes.toString());            }            int statusCode = rsRes.getStatusCode();            wapper.setResultCode("" + statusCode);            wapper.setResultMsg(statusText);            wapper.setSubmitTime(System.currentTimeMillis());            System.out.println("SJ:" + content.getSubject() + " SRV:"                    + content.getServiceId() + " SUB:" + content.getSubmitId()                    + " FROM:" + wapper.getFeeTermId() + " TO:"                    + wapper.getDesTermId() + " MID:" + wapper.getMsgID()                    + " CODE:" + statusCode + " MSG:" + statusText + " LinkID:"                    + wapper.getLinkID());            // if (statusCode > 0) modified by chtm 2006.1.16            if (statusCode == 1000) {                Logger.logMT(wapper);            } else {                int retry = wapper.getRetry();                if (retry > 0) {                    wapper.setRetry(retry - 1);                    SubmitQueue.addMessage(wapper);                } else {                    Logger.logMT(wapper);                }            }        } catch (Exception e) {            e.printStackTrace();            System.out.println("send error::" + e.toString());        }    } 


smil内容:
XML code
<smil><head><meta name='title' content='测试杂志' /><meta name='author' content='star'/><layout><root-layout width='176' height='220'/><region id='vedio' width='90>>' height='90>>' fit='meet'/><region id='image' width='100>>' height='100>>' fit='meet'/><region id='text' width='100>>' height='100>>' fit='scroll'/></layout></head><body><par dur='10s'><audio src='http://121.14.37.211:8080/upload/res/2008/11/18/'/><img src='/data/resin/admin/skin/admin/logos/article/20090207175237.jpg' region='image' /></par><par><text src='/data/resin/admin/skin/admin/WEB-INF/temp/023101_txt0.txt' region='text' /><img src='http://121.14.37.211:8080/uploadfile/20090207150104449.gif' region='image'/><text src='/data/resin/admin/skin/admin/WEB-INF/temp/023101_txt1.txt' region='text' /></par><par><text src='/data/resin/admin/skin/admin/WEB-INF/temp/023101_txt0.txt' region='text' /><img src='http://121.14.37.211:8080/uploadfile/20090207150154197.gif' region='image'/><text src='/data/resin/admin/skin/admin/WEB-INF/temp/023101_txt1.txt' region='text' /></par><par></par></body></smil>


发送出去之后smil文件根本没有起作用,每一个附件都单独成了一页。我只要能达到图片和文字能在一页显示,而且能发送多页就OK了,请高手们帮帮忙,比较急,在线等,分不够可加

[解决办法]
没搞过
[解决办法]
加油!
[解决办法]
把mmcontent.setPresentionContent(mmc);换成
 mmcontent.addSubContent(mmc);

热点排行