IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 网络协议 -> Tools-http接口 -> 正文阅读

[网络协议]Tools-http接口

public class SBDemo {
????public static void main(String[] args) throws Exception {

????????String code = null;
????????String funcode = null;
????????File file = new File("C:/Users/Administrator/Desktop/11.txt");
????????File fileLog = new File("C:/Users/Administrator/Desktop/check.txt");
????????FileReader fis = new FileReader(file);
????????BufferedReader br = new BufferedReader(fis);
????????String line = null;
????????while ((line = br.readLine()) != null) {
????????????String[] split = line.split("###########");

????????????code = split[1];
????????????funcode = split[0];

????????????boolean equals = find(code, funcode).subSequence(30, 36).toString().equals("未查询到数据");
????????????System.out.println(code + " ???======= ??"+ funcode + " ????"+ equals);

????????????if (equals) {
????????????????System.out.println(funcode + " ??" + code + "=====不存在");
????????????????FileOutputStream fos = new FileOutputStream(fileLog, true);
????????????????fos.write((funcode + " ??" + code + "=====不存在 \r\n").getBytes());
????????????????fos.flush();

????????????????String send = send(code, funcode);
????????????????fos.write((funcode + " ??" + code+" ???sen====== " + send+" \r\n").getBytes());
????????????????fos.flush();
????????????????fos.close();
????????????} else {
????????????????FileOutputStream fos = new FileOutputStream(fileLog, true);
????????????????fos.write((funcode + " ??" + code + "=====存在 \r\n").getBytes());
????????????????System.out.println(funcode + " ??" + code + "=====存在");
????????????????fos.flush();
????????????????fos.close();
????????????}
????????}
????}

????private static String find(String code, String funcode) throws MalformedURLException, IOException, ProtocolException {
????????String s = "http://182.207.129.68:9081/cqms/view/cqms/CQMS0021.do";
????????final URL url = new URL(s);
????????HttpURLConnection connection = (HttpURLConnection) url.openConnection();
????????connection.setDoInput(true);
????????connection.setDoOutput(true);
????????connection.setRequestMethod("POST");
????????connection.setUseCaches(false);
????????connection.setRequestProperty("Charsert", "UTF-8");
????????connection.setRequestProperty("Accept", "application/json, text/javascript, */*; q=0.01");
????????connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
????????connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.9");
????????connection.setRequestProperty("Connection", "Keep-Alive");
????????connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
????????connection.setRequestProperty("Cookie", "JSESSIONID=0000vKlZyCbOjVZnpaf-ZxqvsDJ:-1");
????????connection.setRequestProperty("Host", "182.207.129.68:9081");
????????connection.setRequestProperty("Origin", "http://182.207.129.68:9081");
????????connection.setRequestProperty("Referer", "http://182.207.129.68:9081/cqms/view/cqms/ewp_check.html");
????????connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36");
????????connection.setRequestProperty("X-Requested-With", "XMLHttpRequest");
????????connection.setConnectTimeout(10000);
????????StringBuilder sb = new StringBuilder();
????????sb.append("SYS=BMOS");
????????sb.append("&SUN_SYS=");
????????sb.append("&FUNC_CODE=" + funcode);
????????sb.append("&TRAN_CODE=" + code);
????????sb.append("&PLUG_CODE=");


????????DataOutputStream out = new DataOutputStream(connection.getOutputStream());
????????out.write(sb.toString().getBytes("utf-8"));

????????out.flush();
????????out.close();

????????final StringBuffer responseBuffer = new StringBuffer();
????????if (connection.getResponseCode() == 200) {
????????????BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
????????????String line = in.readLine();
????????????while (line != null) {
????????????????responseBuffer.append(line);
????????????????line = in.readLine();
????????????}
????????}
????????System.out.println(responseBuffer.toString());
????????return responseBuffer.toString();
????}


????public static String send(String code, String funCode) throws MalformedURLException, IOException,
????????????ProtocolException, UnsupportedEncodingException {
????????final URL url = new URL("http://182.207.129.68:9081/cqms/view/cqms/CQMS0022.do");
????????HttpURLConnection connection = (HttpURLConnection) url.openConnection();

????????connection.setDoInput(true);
????????connection.setDoOutput(true);
????????connection.setRequestMethod("POST");
????????connection.setUseCaches(false);
????????connection.setRequestProperty("Charsert", "UTF-8");
????????connection.setRequestProperty("Connection", "Keep-Alive");
????????connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
????????connection.setRequestProperty("Cookie", "JSESSIONID=0000vKlZyCbOjVZnpaf-ZxqvsDJ:-1");
????????connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36");
????????connection.setConnectTimeout(10000);

????????StringBuilder sb = new StringBuilder();
????????sb.append("SYS=BMOS");
????????sb.append("&SUB_SYS=BMOS");
????????sb.append("&TRAN_CODE=" + code);
????????sb.append("&PLUG_CODE=");
????????sb.append("&FUNC_CODE=" + funCode);
????????sb.append("&UP_DATOR=" + URLEncoder.encode("王尧", "UTF-8"));
????????sb.append("&PAGE_CODE=");
????????sb.append("&PAGE_NAME=");
????????sb.append("&NOTE=");

????????String string = sb.toString();
????????OutputStream out = connection.getOutputStream();
????????out.write(string.getBytes("UTF-8"));

????????out.flush();
????????out.close();

????????final StringBuffer responseBuffer = new StringBuffer();
????????if (connection.getResponseCode() == 200) {
????????????BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
????????????String line = in.readLine();
????????????while (line != null) {
????????????????responseBuffer.append(line);
????????????????line = in.readLine();
????????????}
????????}

????????System.out.println(responseBuffer);
????????return responseBuffer.toString();
????}
}

=============================

public static String sendPostHttpRequest( String requestUrl, String requestData ,String requestMethod ,String token) throws Exception{

????//token使用base64编码后上送
????byte[] decodeBuffer =token.getBytes("UTF-8");
????BASE64Encoder encoder = new BASE64Encoder();
????String token_base64 ?= encoder.encode(decodeBuffer);

????OutputStream out = null;
????BufferedReader in = null;
????HttpURLConnection connection = null;
????try {
????????// 发送数据
????????DefaultHttpClient client = new DefaultHttpClient();
????????HttpPost post = new HttpPost(requestUrl);
????????StringEntity stringEntity = new StringEntity(requestData);
????????post.setEntity(stringEntity);
????????post.setHeader("Content-Type" ,"application/json");
????????//post.setHeader("guwp-token","3590cd3585ee7efc5a5743ee8eee3dde");
????????post.setHeader("muop-token",token_base64);
????????HttpResponse execute = client.execute(post);
????????String string = EntityUtils.toString(execute.getEntity());
????????System.out.println("返回数据是="+string);
????????return string;
????} catch (IOException e) {
????????throw new RuntimeException("获取连接失败! ", e);
????} finally {
????????try {
????????????if (out != null) {
????????????????out.close();
????????????}
????????} catch (IOException e) {
????????}
????????try {
????????????if (in != null) {
????????????????in.close();
????????????}
????????} catch (Exception e2) {
????????}
????????try {
????????????if (connection != null) {
????????????????connection.disconnect();
????????????}
????????} catch (Exception e2) {
????????}
????}

}

  网络协议 最新文章
使用Easyswoole 搭建简单的Websoket服务
常见的数据通信方式有哪些?
Openssl 1024bit RSA算法---公私钥获取和处
HTTPS协议的密钥交换流程
《小白WEB安全入门》03. 漏洞篇
HttpRunner4.x 安装与使用
2021-07-04
手写RPC学习笔记
K8S高可用版本部署
mySQL计算IP地址范围
上一篇文章      下一篇文章      查看所有文章
加:2021-11-17 13:06:20  更:2021-11-17 13:08:44 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 6:45:25-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码