![彩信实验报告电信增值业务一new_第1页](http://file1.renrendoc.com/fileroot_temp2/2020-12/17/5cc6ce37-1352-455e-b6f0-39c5a2afb1db/5cc6ce37-1352-455e-b6f0-39c5a2afb1db1.gif)
![彩信实验报告电信增值业务一new_第2页](http://file1.renrendoc.com/fileroot_temp2/2020-12/17/5cc6ce37-1352-455e-b6f0-39c5a2afb1db/5cc6ce37-1352-455e-b6f0-39c5a2afb1db2.gif)
![彩信实验报告电信增值业务一new_第3页](http://file1.renrendoc.com/fileroot_temp2/2020-12/17/5cc6ce37-1352-455e-b6f0-39c5a2afb1db/5cc6ce37-1352-455e-b6f0-39c5a2afb1db3.gif)
![彩信实验报告电信增值业务一new_第4页](http://file1.renrendoc.com/fileroot_temp2/2020-12/17/5cc6ce37-1352-455e-b6f0-39c5a2afb1db/5cc6ce37-1352-455e-b6f0-39c5a2afb1db4.gif)
![彩信实验报告电信增值业务一new_第5页](http://file1.renrendoc.com/fileroot_temp2/2020-12/17/5cc6ce37-1352-455e-b6f0-39c5a2afb1db/5cc6ce37-1352-455e-b6f0-39c5a2afb1db5.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验一:大汉三通平台熟悉认知以及开通服务实验二:实现网页版彩信发送界面实验三:基于MMS的实现实验四:TCP和SOCKET编程电信增值业务一之彩信 实验报告 任课教师: 实验地点:实验时间: 小组成员:实验二 网页版彩信发送页面(修改版)代码:Client.jsp function actionEdit() var phone = document.getElementById(phone).value;var produce = document.getElementById(produce).value;if (phone.length = 0) alert(电话号码不能为空);retur
2、n falseif (produce = -1) alert(请选择产品);return falsereturn true; 彩信发送页面 手机号码: 选择产品: 请选择 %List list=(List)request.getAttribute(list); for(int i=0;i option value= 彩信填写 收件号码: 标题: 内容: 附加文件选择 上传人: 上传文件: Index.jsp实验截图:实验三 实验代码:MMS.javapackage com.cq.view;import java.awt.event.ActionEvent;import java.awt.eve
3、nt.ActionListener;import java.awt.FlowLayout;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.io.InputStream;import javax.swing.*;import javax.swing.filechooser.FileFilter;import com.cq.main.Clien
4、tInit;import com.cq.util.CommonUtil;import sun.misc.BASE64Encoder;public class MMS extends JFrame private String sendAddress = 6:8080/mms/http/SendMms;private String userName = 2010214442;private String password = 123;private String serviceId = 2;private String channelId = 1;privat
5、e String phone = ;private String subject = 重庆早报(20120114);String filePath;JFrame jf = new JFrame(发彩信);/顶层容器JPanel jp = new JPanel(); /面板容器JLabel l_name = new JLabel(电话号码:);static JTextField t_name = new JTextField(10);JButton seleFile = new JButton(附件);JLabel lb = new JLabel(短信内容: );static JTextArea
6、 t_test = new JTextArea(12,18);JButton send = new JButton(发送);JButton cancel = new JButton(取消);public MMS() jp.add(l_name);jp.add(t_name);jp.add(seleFile);jp.add(lb);jp.add(t_test);jp.add(send);jp.add(cancel);jf.add(jp);/ 事件OK按钮监听seleFile.addActionListener(new ActionListener() public void actionPerf
7、ormed(ActionEvent e) JFileChooser fileChooser = new JFileChooser(D:);int returnVal = fileChooser.showOpenDialog(fileChooser);filePath = fileChooser.getSelectedFile().getAbsolutePath();/ 这个就是你选择的文件夹的路径System.out.println(filePath););send.addActionListener(new ActionListener() public void actionPerform
8、ed(ActionEvent e) send(filePath););/ 事件Cancel按钮监听cancel.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) System.exit(0););jf.setVisible(true);jf.setSize(230, 350);jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);jf.setLocation(500, 270);public void send(String filepath)
9、 ClientInit client = new ClientInit();/ 1.获取下发内容String content = client.getMMSContent(filepath);/ D:/test/mms.zip/ 2.下发StringBuffer sendParam = new StringBuffer();phone = t_name.getText();sendParam.append(phone= + phone);sendParam.append(&userName= + userName);sendParam.append(&password= + CommonUti
10、l.MD5Encode(password);sendParam.append(&serviceId= + serviceId);sendParam.append(&channelId= + channelId);sendParam.append(&subject= + subject);sendParam.append(&content= + content);String resp = CommonUtil.connectURL(String.valueOf(sendParam),sendAddress);System.out.println(Send MMS response: + res
11、p);public String getMMSContent(String path) String result = ;InputStream is = null;try BASE64Encoder encoder = new BASE64Encoder();is = new FileInputStream(new File(path);byte bAry = new byteis.available();is.read(bAry);result = encoder.encode(bAry); catch (Exception e) System.out.println(e); finall
12、y if (null != is) try is.close(); catch (IOException e) System.out.println(e);return result;public static void main(String args) new MMS();ClientInit.javapackage com.cq.main;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import sun.misc.BASE6
13、4Encoder;import com.cq.util.CommonUtil;public class ClientInit private static String sendAddress = 6:8080/mms/http/SendMms;private static String userName = 2010214442;private static String password = 123;private static String serviceId = 2;private static String channelId = 1;privat
14、e String phone =private String subject = 重庆早报(20120114);public static void main(String args) ClientInit client = new ClientInit();/ 1.获取下发内容String content = client.getMMSContent(D:/test/mms.zip);/ 2.下发StringBuffer sendParam = new StringBuffer();sendParam.append(phone= + client.phone);se
15、ndParam.append(&userName= + userName);sendParam.append(&password= + CommonUtil.MD5Encode(password);sendParam.append(&serviceId= + serviceId);sendParam.append(&channelId= + channelId);sendParam.append(&subject= + client.subject);sendParam.append(&content= + content);String resp = CommonUtil.connectUR
16、L(String.valueOf(sendParam), sendAddress);System.out.println(Send MMS response: + resp);public String getMMSContent(String path) String result = ;InputStream is = null;try BASE64Encoder encoder = new BASE64Encoder();is = new FileInputStream(new File(path);byte bAry = new byteis.available();is.read(b
17、Ary);result = encoder.encode(bAry); catch (Exception e) System.out.println(e); finally if (null != is) try is.close(); catch (IOException e) System.out.println(e);return result;CommonUtil.javapackage com.cq.util;import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.OutputStre
18、am;import .HttpURLConnection;import .URL;import java.security.MessageDigest;public class CommonUtil public static String connectURL(String commString, String address) HttpURLConnection urlConn = null;String rec_string = ;URL url = null;try url = new URL(address);urlConn = (HttpURLCon
19、nection) url.openConnection();urlConn.setConnectTimeout(30000);urlConn.setReadTimeout(30000);urlConn.setRequestMethod(POST);urlConn.setDoOutput(true);OutputStream out = urlConn.getOutputStream();out.write(commString.getBytes(UTF-8);out.flush();out.close();BufferedReader rd = new BufferedReader(new I
20、nputStreamReader(urlConn.getInputStream(), UTF-8);StringBuffer sb = new StringBuffer();int ch;while (ch = rd.read() -1) sb.append(char) ch);rec_string = sb.toString().trim();rd.close(); catch (Exception e) rec_string = -107; finally if (urlConn != null) urlConn.disconnect();return rec_string;public
21、static String MD5Encode(String sourceString) String resultString = null;try resultString = new String(sourceString);MessageDigest md = MessageDigest.getInstance(MD5);resultString = byte2hexString(md.digest(resultString.getBytes(); catch (Exception ex) System.out.println(ex);return resultString;priva
22、te static String byte2hexString(byte bytes) StringBuffer bf = new StringBuffer(bytes.length * 2);for (int i = 0; i bytes.length; i+) if (bytesi & 0xff) 0) msg = Encoding.UTF8.GetString(buff); client.Close(); catch(Exception ) throw new Exception(); return msg; CommonUtil.csusing System;using System.
23、Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Net;using System.Security.Policy;namespace demo public class CommonUtilpublic static string connectURL(string cString, String address)WebRequest wr = WebRequest.Create(address); wr.Method = post;StringBuilder urlEncoded = new StringBuilder(); byte someby
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 装修合同补充协议书样本合集
- 不侵权保证书合集
- 离婚协议书应该怎么写合集
- 高利贷借款合同范本合集
- 北京市精装修商品房认购合同书合集
- 怎样写解除租赁合同合集
- 2024年欧洲杠杆式手推车市场主要企业市场占有率及排名
- 执业药师之中药学综合知识与技能自测提分题库加答案
- 在线网课知道智慧《程序设计实践与进阶》单元测试考核答案
- 电子商务平台与供应商合作协议
- GB/T 3880.2-2024一般工业用铝及铝合金板、带材第2部分:力学性能
- 2024安全月主题培训:人人讲安全个个会应急-畅通生命通道
- C语言编程方法与思想智慧树知到答案2024年北京航空航天大学
- 中国现代史必背知识清单初中历史2024年中考一轮复习
- 艺术中国智慧树知到期末考试答案2024年
- 安全生产监督人员培训
- MOOC 工科物理实验I-北京科技大学 中国大学慕课答案
- 中学生科学探究能力培养的策略
- 2024年青海省中考初中学业水平考试一模生物试题
- 可持续建筑技术B智慧树知到期末考试答案2024年
- 《区块链金融》考试复习题库(含答案)
评论
0/150
提交评论