版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、電信增值業(yè)務(wù)一之彩信 實(shí)驗(yàn)報(bào)告 任課教師: 實(shí)驗(yàn)地點(diǎn):實(shí)驗(yàn)時(shí)間: 小構(gòu)成員:實(shí)驗(yàn)二 網(wǎng)頁(yè)版彩信發(fā)送頁(yè)面(修改版)代碼:Client.jsp function actionEdit() var phone = document.getElementById(phone).value;var produce = document.getElementById(produce).value;if (phone.length = 0) alert(電話號(hào)碼不能為空);return falseif (produce = -1) alert(請(qǐng)選擇產(chǎn)品);return falsereturn true;
2、彩信發(fā)送頁(yè)面 手機(jī)號(hào)碼: 選擇產(chǎn)品: 請(qǐng)選擇 %List list=(List)request.getAttribute(list); for(int i=0;i option value= 彩信填寫(xiě) 收件號(hào)碼: 標(biāo)題: 內(nèi)容: 附加文獻(xiàn)選擇 上傳人: 上傳文獻(xiàn): Index.jsp實(shí)驗(yàn)截圖:實(shí)驗(yàn)三 實(shí)驗(yàn)代碼:MMS.javapackage com.cq.view;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.FlowLayout;import java.io.Fil
3、e;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.ClientInit;import com.cq.util.CommonUtil;import sun.misc.BASE64Encod
4、er;public class MMS extends JFrame private String sendAddress = :8080/mms/http/SendMms;private String userName = 214442;private String password = 123;private String serviceId = 2;private String channelId = 1;private String phone = ;private String subject = 重慶早報(bào)();String filePath;JFrame jf = new JFra
5、me(發(fā)彩信);/頂層容器JPanel jp = new JPanel(); /面板容器JLabel l_name = new JLabel(電話號(hào)碼:);static JTextField t_name = new JTextField(10);JButton seleFile = new JButton(附件);JLabel lb = new JLabel(短信內(nèi)容: );static JTextArea t_test = new JTextArea(12,18);JButton send = new JButton(發(fā)送);JButton cancel = new JButton(取消)
6、;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按鈕監(jiān)聽(tīng)seleFile.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) JFileChooser fileChooser = new JFileChooser(D:);int returnVal = fileChoos
7、er.showOpenDialog(fileChooser);filePath = fileChooser.getSelectedFile().getAbsolutePath();/ 這個(gè)就是你選擇旳文獻(xiàn)夾旳途徑System.out.println(filePath););send.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) send(filePath););/ 事件Cancel按鈕監(jiān)聽(tīng)cancel.addActionListener(new ActionListener()
8、 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) ClientInit client = new ClientInit();/ 1.獲取下發(fā)內(nèi)容String content = client.getMMSContent(filepath
9、);/ D:/test/mms.zip/ 2.下發(fā)StringBuffer sendParam = new StringBuffer();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= +
10、 channelId);sendParam.append(&subject= + subject);sendParam.append(&content= + content);String resp = CommonUtil.connectURL(String.valueOf(sendParam),sendAddress);System.out.println(Send MMS response: + resp);public String getMMSContent(String path) String result = ;InputStream is = null;try BASE64E
11、ncoder 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); finally if (null != is) try is.close(); catch (IOException e) System.out.println(e);return result;pu
12、blic 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.BASE64Encoder;import com.cq.util.CommonUtil;public class ClientInit private static String sendAddre
13、ss = :8080/mms/http/SendMms;private static String userName = 214442;private static String password = 123;private static String serviceId = 2;private static String channelId = 1;private String phone = 1871635;private String subject = 重慶早報(bào)();public static void main(String args) ClientInit client = new
14、 ClientInit();/ 1.獲取下發(fā)內(nèi)容String content = client.getMMSContent(D:/test/mms.zip);/ 2.下發(fā)StringBuffer sendParam = new StringBuffer();sendParam.append(phone= + client.phone);sendParam.append(&userName= + userName);sendParam.append(&password= + CommonUtil.MD5Encode(password);sendParam.append(&serviceId= +
15、 serviceId);sendParam.append(&channelId= + channelId);sendParam.append(&subject= + client.subject);sendParam.append(&content= + content);String resp = CommonUtil.connectURL(String.valueOf(sendParam), sendAddress);System.out.println(Send MMS response: + resp);public String getMMSContent(String path)
16、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); finally if (null != is) try is.close(); catch (IOE
17、xception e) System.out.println(e);return result;CommonUtil.javapackage com.cq.util;import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.OutputStream;import .HttpURLConnection;import .URL;import java.security.MessageDigest;public class CommonUtil public static String connectU
18、RL(String commString, String address) HttpURLConnection urlConn = null;String rec_string = ;URL url = null;try url = new URL(address);urlConn = (HttpURLConnection) url.openConnection();urlConn.setConnectTimeout(30000);urlConn.setReadTimeout(30000);urlConn.setRequestMethod(POST);urlConn.setDoOutput(t
19、rue);OutputStream out = urlConn.getOutputStream();out.write(commString.getBytes(UTF-8);out.flush();out.close();BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), UTF-8);StringBuffer sb = new StringBuffer();int ch;while (ch = rd.read() -1) sb.append(char) ch);rec_s
20、tring = sb.toString().trim();rd.close(); catch (Exception e) rec_string = -107; finally if (urlConn != null) urlConn.disconnect();return rec_string;public static String MD5Encode(String sourceString) String resultString = null;try resultString = new String(sourceString);MessageDigest md = MessageDig
21、est.getInstance(MD5);resultString = byte2hexString(md.digest(resultString.getBytes(); catch (Exception ex) System.out.println(ex);return resultString;private static String byte2hexString(byte bytes) StringBuffer bf = new StringBuffer(bytes.length * 2);for (int i = 0; i bytes.length; i+) if (bytesi &
22、 0 xff) 0) msg = Encoding.UTF8.GetString(buff); client.Close(); catch(Exception ) throw new Exception(); return msg; CommonUtil.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.
23、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 somebytes = null; if (
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 17925-2024氣瓶對(duì)接焊縫X射線數(shù)字成像檢測(cè)
- Tripetroselinin-1-2-3-Tri-6-Z-octadecenoyl-glycerol-生命科學(xué)試劑-MCE-1244
- Diethylene-glycol-d8-2-2-Oxybis-ethan-1-ol-d-sub-8-sub-生命科學(xué)試劑-MCE-5883
- 2025年度掛車(chē)司機(jī)運(yùn)輸合同違約責(zé)任與賠償合同
- 2025年度網(wǎng)絡(luò)安全行業(yè)競(jìng)業(yè)限制協(xié)議生效細(xì)則及數(shù)據(jù)隱私
- 二零二五年度創(chuàng)業(yè)公司股權(quán)分配及股權(quán)激勵(lì)協(xié)議
- 2025年度消防電梯采購(gòu)與應(yīng)急救援系統(tǒng)配套合同
- 2025年度水果種植基地農(nóng)業(yè)保險(xiǎn)合同
- 2025年度綠色能源股權(quán)合作開(kāi)發(fā)合同
- 施工現(xiàn)場(chǎng)施工防傳染病制度
- 鉗工考試題及參考答案
- 醫(yī)藥高等數(shù)學(xué)知到章節(jié)答案智慧樹(shù)2023年浙江中醫(yī)藥大學(xué)
- 中央企業(yè)商業(yè)秘密安全保護(hù)技術(shù)指引2015版
- 第4章操作臂的雅可比
- 人教版初中英語(yǔ)八年級(jí)下冊(cè) 單詞默寫(xiě)表 漢譯英
- 學(xué)校網(wǎng)絡(luò)信息安全管理辦法
- 中國(guó)古代文學(xué)史 馬工程課件(下)21第九編晚清文學(xué) 緒論
- 2023年鐵嶺衛(wèi)生職業(yè)學(xué)院高職單招(語(yǔ)文)試題庫(kù)含答案解析
- 外科學(xué)-第三章-水、電解質(zhì)代謝紊亂和酸堿平衡失調(diào)課件
- 人事測(cè)評(píng)理論與方法-課件
- 最新卷宗的整理、裝訂(全)課件
評(píng)論
0/150
提交評(píng)論