彩信实验报告电信增值业务一_第1页
彩信实验报告电信增值业务一_第2页
彩信实验报告电信增值业务一_第3页
彩信实验报告电信增值业务一_第4页
彩信实验报告电信增值业务一_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

彩信实验报告电信增值业务一实验一:大汉三通平台熟悉认知以及开通服务实验二:实现网页版彩信发送界面实验三:基于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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论