版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
彩信实验报告电信增值业务一实验一:大汉三通平台熟悉认知以及开通服务实验二:实现网页版彩信发送界面实验三:基于MMS的实现实验四:TCP和SOCKET编程电信增值业务一之彩信实验报告任课教师:实验地点:实验时间:小组成员:实验二网页版彩信发送页面(修改版)代码:Client.jsp<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><title></title> <scripttype="text/javascript"> functionactionEdit(){ varphone=document.getElementById("phone").value; varproduce=document.getElementById("produce").value; if(phone.length==0){ alert("电话号码不能为空"); returnfalse} if(produce==-1){ alert("请选择产品"); returnfalse} returntrue;}</script></head><body><palign="center">彩信发送页面</p><formid="form1"name="form1"method="post"action="servlet/fileServlet"enctype="multipart/form-data"><tableborder="0"align="center"><tr><tdwidth="35%"align="right"style="background-color:rgb(255,128,0);">手机号码:</td><tdstyle="background-color:rgb(255,128,0);"><inputtype="text"name="phone"maxlength="150"size="50"></td></tr><tr><tdalign="right"style="background-color:rgb(255,128,0);">选择产品:</td><tdstyle="background-color:rgb(255,128,0);"><selectname="produce"><optionvalue="-1">请选择</option><%List<String>list=(List)request.getAttribute("list");for(inti=0;i<list.size();i++){%><optionvalue="<%=list.get(i)%>"><%=list.get(i)%></option><%}%></select></td></tr><tralign="center"><tdalign="right"style="background-color:rgb(255,128,0);"><inputtype="submit"onclick="javascript:returnactionEdit()"value="发送"></td><tdalign="left"style="background-color:rgb(255,128,0);"><inputtype="reset"value="重置"></td></tr></table></form><palign="center">彩信填写</p><formid="form1"name="form1"method="post"action="servlet/fileServlet"enctype="multipart/form-data"><tableborder="0"align="center"><tr><tdwidth="35%"align="right"style="background-color:rgb(255,128,128);">收件号码:</td><tdstyle="background-color:rgb(255,128,128);"><inputtype="text"name="phoneto"maxlength="150"size="50"></td></tr><tr><tdwidth="35%"align="right"style="background-color:rgb(255,128,128);">标题:</td><tdstyle="background-color:rgb(255,128,128);"><inputtype="text"name="title"maxlength="150"size="50"></td></tr><tr><tdwidth="5%"align="right"style="background-color:rgb(255,128,128);">内容:</td><tdstyle="background-color:rgb(255,128,128);"><inputtype="text"name="test"maxlength="150"size="50"></td></tr><tralign="center"><tdalign="right"style="background-color:rgb(255,128,128);"><inputtype="submit"onclick="javascript:returnactionEdit()"value="发送"></td><tdalign="left"style="background-color:rgb(255,128,128);"><inputtype="reset"value="重置"></td></tr></table></form><palign="center">附加文件选择</p><formid="form1"name="form1"method="post"action="servlet/fileServlet"enctype="multipart/form-data"><tableborder="0"align="center"><tr><tdstyle="background-color:rgb(0,255,255);">上传人:</td><tdstyle="background-color:rgb(0,255,255);"><inputname="name"type="text"id="name"size="20"></td></tr><tr><tdstyle="background-color:rgb(0,255,255);">上传文件:</td><tdstyle="background-color:rgb(0,255,255);"><inputname="file"type="file"size="20"></td></tr><tr><tdstyle="background-color:rgb(0,255,255);"></td><tdstyle="background-color:rgb(0,255,255);"><inputtype="submit"name="submit"value="提交"><inputtype="reset"name="reset"value="重置"></td></tr></table></form></body></html>Index.jsp<%request.getRequestDispatcher("/http/MmsService").forward(request,response);%>实验截图:实验三实验代码:MMS.javapackagecom.cq.view;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.FlowLayout;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.FileReader;importjava.io.IOException;importjava.io.InputStream;importjavax.swing.*;importjavax.swing.filechooser.FileFilter;importcom.cq.main.ClientInit;importcom.cq.util.CommonUtil;importsun.misc.BASE64Encoder;publicclassMMSextendsJFrame{privateStringsendAddress="6:8080/mms/http/SendMms"; privateStringuserName="2010214442"; privateStringpassword="123"; privateStringserviceId="2"; privateStringchannelId="1"; privateStringphone=""; privateStringsubject="重庆早报(20120114)"; StringfilePath; JFramejf=newJFrame("发彩信");//顶层容器 JPaneljp=newJPanel();//面板容器 JLabell_name=newJLabel("电话号码:"); staticJTextFieldt_name=newJTextField(10); JButtonseleFile=newJButton("附件"); JLabellb=newJLabel("短信内容:"); staticJTextAreat_test=newJTextArea(12,18); JButtonsend=newJButton("发送"); JButtoncancel=newJButton("取消");publicMMS(){ 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(newActionListener(){publicvoidactionPerformed(ActionEvente){ JFileChooserfileChooser=newJFileChooser("D:\\"); intreturnVal=fileChooser.showOpenDialog(fileChooser); filePath=fileChooser.getSelectedFile().getAbsolutePath();//这个就是你选择的文件夹的路径 System.out.println(filePath);}});send.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ send(filePath);}});//事件Cancel按钮监听 cancel.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ System.exit(0);}});jf.setVisible(true);jf.setSize(230,350); jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE); jf.setLocation(500,270);}publicvoidsend(Stringfilepath){ ClientInitclient=newClientInit(); //1.获取下发内容Stringcontent=client.getMMSContent(filepath);//"D:/test/mms.zip"//2.下发 StringBuffersendParam=newStringBuffer(); phone=t_name.getText(); sendParam.append("phone="+phone); sendParam.append("&userName="+userName); sendParam.append("&password="+CommonUtil.MD5Encode(password)); sendParam.append("&serviceId="+serviceId);sendParam.append("&channelId="+channelId); sendParam.append("&subject="+subject); sendParam.append("&content="+content); Stringresp=CommonUtil.connectURL(String.valueOf(sendParam), sendAddress);System.out.println("SendMMSresponse:"+resp);} publicStringgetMMSContent(Stringpath){ Stringresult=""; InputStreamis=null; try{BASE64Encoderencoder=newBASE64Encoder(); is=newFileInputStream(newFile(path)); byte[]bAry=newbyte[is.available()]; is.read(bAry); result=encoder.encode(bAry); }catch(Exceptione){System.out.println(e);}finally{if(null!=is){try{is.close();}catch(IOExceptione){ System.out.println(e); }}}returnresult;} publicstaticvoidmain(String[]args){ newMMS();}}ClientInit.javapackagecom.cq.main;importjava.io.File;实验四实验代码:Form1.csusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.IO;namespacedemo{publicpartialclassForm1:Form{privatestaticStringsendAddress;privatestaticStringuserName;privatestaticStringpassword;privatestaticStringserviceId;privatestaticStringchannelId;publicStringphone;publicStringsubject;publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){textBox1.Text="6:8080/mms/http/SendMms";textBox2.Text="2010214787";textBox3.Text="***";textBox4.Text="2";textBox5.Text="1";textBox6.Text=;textBox7.Text="重庆邮电大学欢迎您";textBox8.Text="D:/mms.zip";comboBox1.SelectedIndex=0;}publicStringgetMMSContent(Stringpath){stringresult="";byte[]b_data=newbyte[2500];char[]c_data=newchar[2500];try{lock(this){if(File.Exists(path)==false){MessageBox.Show("文件不存在","提示信息");}else{FileStreamfs=newFileStream(path,FileMode.Open);fs.Seek(0,SeekOrigin.Begin);fs.Read(b_data,0,2000);Decoderd=Encoding.UTF8.GetDecoder();d.GetChars(b_data,0,b_data.Length,c_data,0);result=newstring(c_data);}}returnresult;}catch(IOExceptione){return(e.Message);}}privatevoidbutton1_Click(objectsender,EventArgse){sendAddress=textBox1.Text.Trim();userName=textBox2.Text.Trim();password=textBox3.Text.Trim();serviceId=textBox4.Text.Trim();channelId=textBox5.Text.Trim();phone=textBox6.Text.Trim();subject=textBox7.Text.Trim();stringpath=textBox8.Text.Trim();stringcontent=getMMSContent(path);IPEndPointpoint=newIPEndPoint(IPAddress.Parse("6"),8080);stringsendParam="phone="+phone+"&userName="+userName+"&password="+password+"&serviceId="+serviceId+"&channelId="+channelId+"&subject="+subject+"&content="+content;try{switch(comboBox1.SelectedIndex){case0:stringdata=CommonUtil.connectURL(sendParam,sendAddress);MessageBox.Show("成功发送:"+data,"结果");break;case1:stringmsg=mySockets.send(sendParam,point);MessageBox.Show("返回:"+msg,"结果");break;default:MessageBox.Show("请选择正确的发送方式!","提示信息");break;}}catch(Exceptionex){MessageBox.Show(ex.Message,"警告信息");}}privatevoidbutton2_Click(objectsender,EventArgse){if(openFileDialog1.ShowDialog()==DialogResult.OK){textBox8.Text=openFileDialog1.FileName;}}privatevoidlabel2_Click(objectsender,EventArgse){}privatevoidlabel3_Click(objectsender,EventArgse){}}}mySocket.csusingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Net;usingSystem.Net.Sockets;namespacedemo{classmySockets{publicstaticstringsend(stringmessage,IPEndPointpoint){NetworkStreamstream;byte[]buff=newbyte[512];stringmsg="";try{TcpClientclient=newTcpClient();client.Connect(point);if(client.Connected){byte[]buff2=Encoding.UTF8.GetBytes(message);stream=client.GetStream();stream.Write(buff2,0,buff2.Length);intbytes=stream.Read(buff,0,512);if(bytes>0){msg=Encoding.UTF8.GetString(buff);}client.Close();}}catch(Exception){thrownewException();}returnmsg;}}}CommonUtil.csusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;u
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 25085.7-2026道路车辆汽车电缆第7部分:交流30 V或直流60 V圆形、护套、屏蔽或非屏蔽、多芯或单芯铜导体电缆的尺寸和要求
- 脑梗死护理竞赛案例分享
- 肋骨骨折患者的康复评估方法
- 重庆对外经贸学院《植物学及技术》2024-2025学年第二学期期末试卷
- 浙江省丽水市莲都区2026年初三综合练习(三模)化学试题含解析
- 吉林省前郭县市级名校2026年初三第一次模拟考试-数学试题含解析
- 广东省广州白云广雅实验校2026届初三下学期4月诊断考试物理试题含解析
- 辽宁省大石桥市水源镇2026年初三下学期化学试题第一次月考含解析
- 2026年山西省朔州市朔城区四中学初三5月第二次自主练习数学试题含解析
- 山东省莱城区刘仲莹中学2026年初三下学期中考考前质量检测试题三(5月模拟)数学试题含解析
- 2026年滁州职业技术学院单招综合素质考试题库附答案详解
- 2026春统编版三年级下册道德与法治每课知识点清单
- 2025年建筑安全员c2考试题及答案
- 2025中国国新控股有限责任公司招聘7人笔试历年常考点试题专练附带答案详解
- 东北三省三校2026年高三下学期高考第一次联合模拟考试政治试卷
- 2026秋招:平安银行笔试题及答案
- 2026年六安职业技术学院单招职业适应性考试题库附参考答案详解ab卷
- 2026广东江门职业技术学院管理教辅人员招聘4人备考题库带答案详解(基础题)
- 货梯使用专项安全培训课件
- (2025版)国家基层高血压防治管理指南2025版课件
- 女职工安全教育培训内容课件
评论
0/150
提交评论